What is the relationship between Mapper sql statement fields and entity class attribute names

What is the relationship between Mapper sql statement fields and entity class attribute names

background:

1. There is a notification table in the database

You can see the

  • gmt_create,
  • notifier_name,
  • outer_title

These three fields are underlined.

2. The entity class corresponding to this table is

public class Notification {
  private Long id;
  private Long notifier;
  private Long receiver;
  private Long outerId;
  private Integer type;
  private Long gmtCreate;
  private Integer status;
  private String notifierName;
  private String outerTitle;
}

Use camelCase when writing actual Java code

Note whether camel case mapping is enabled in application.properties

#CamelCase Mapping
mybatis.configuration.map-underscore-to-camel-case=true

3. There is an insert statement in Mapper

//0.Insert a notification
@Insert("insert into questions (title,description,gmt_create,gmt_modified,creator,tag) values ​​(#{title},#{description},#{gmtCreate},#{gmtModified},#{creator},#{tag})")
void createQuestion(Question question);

Conclusion: When doing placeholder, the content in #{} should be gmtCreate

Be careful when writing, writing it as gmt_create may result in an error

There is no getter for property named 'gmt_create' in 'class com.example.com

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • MyBatis directly executes SQL using SqlMapper
  • Detailed explanation of sqlSessionFactory injection method of MapperScannerConfigurer
  • Detailed introduction to the extension and application of SqlMapper configuration in Mybatis (1)
  • How to use XSD to verify the Mybatis SqlMapper configuration file (2)
  • How to use XSD to verify the Mybatis SqlMapper configuration file (1)
  • Detailed explanation of MyBatis's getMapper() interface, resultMap tag, Alias, extracting sql columns as much as possible, and dynamic operations
  • Analysis and solution of the error in executing MyBatis MapperProvider MessageFormat splicing batch SQL statements

<<:  Implementation of Docker deployment of web projects

>>:  Vue uses el-table to dynamically merge columns and rows

Recommend

How to dynamically add a volume to a running Docker container

Someone asked me before whether it is possible to...

How to configure CDN scheduling using Nginx_geo module

Introducing the Geo module of Nginx The geo direc...

The perfect solution for MySql version problem sql_mode=only_full_group_by

1. Check sql_mode select @@sql_mode The queried v...

Detailed tutorial on VMware installation of Linux CentOS 7.7 system

How to install Linux CentOS 7.7 system in Vmware,...

Implementing Priority Queue in JavaScript

Table of contents 1. Introduction to priority que...

CSS style reset and clear (to make different browsers display the same effect)

In order to make the page display consistent betwe...

How to export mysql table structure to excel

The requirements are as follows Export the table ...

How to authorize remote connections in MySQL in Linux

Note: Other machines (IP) cannot connect to the M...

HTML iframe usage summary collection

Detailed Analysis of Iframe Usage <iframe frame...

Implementation of running springboot project with Docker

Introduction: The configuration of Docker running...

HTML insert image example (html add image)

Inserting images into HTML requires HTML tags to ...

Vue uses mixins to optimize components

Table of contents Mixins implementation Hook func...

Add unlimited fonts to your website with Google Web Fonts

For a long time, website development was hampered...