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 deploy Confluence and jira-software in Docker

version: centos==7.2 jdk==1.8 confluence==6.15.4 ...

DOCTYPE Document Type Declaration (Must-Read for Web Page Lovers)

DOCTYPE DECLARATION At the top of every page you w...

About MYSQL, you need to know the data types and operation tables

Data Types and Operations Data Table 1.1 MySQL ty...

Install Docker for Windows on Windows 10 Home Edition

0. Background Hardware: Xiaomi Notebook Air 13/In...

Summary of tips for making web pages

Preface This article mainly summarizes some of th...

Parsing Linux source code epoll

Table of contents 1. Introduction 2. Simple epoll...

Summary of Creating and Using Array Methods in Bash Scripts

Defining an array in Bash There are two ways to c...

Detailed Tutorial on Installing VirtualBox 6.0 on CentOS 8 / RHEL 8

VirtualBox is a free and open source virtualizati...

HTML design pattern daily study notes

HTML Design Pattern Study Notes This week I mainl...

GET POST Differences

1. Get is used to obtain data from the server, wh...

Practical record of vue using echarts word cloud chart

echarts word cloud is an extension of echarts htt...

Native JS to implement real-time clock

Share a real-time clock effect implemented with n...