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

Detailed explanation of CSS animation attribute keyframes

How long has it been since I updated my column? H...

Vue3 (Part 2) Integrating Ant Design Vue

Table of contents 1. Integrate Ant Design Vue 2. ...

Two ways to clear float in HTML

1. Clear floating method 1 Set the height of the ...

Small details of web front-end development

1 The select tag must be closed <select><...

Explaining immutable values ​​in React

Table of contents What are immutable values? Why ...

How to install and configure SSH service in Ubuntu 18.04

Install ssh tool 1. Open the terminal and type th...

Detailed explanation of object literals in JS

Table of contents Preface 1. Set the prototype on...

Detailed tutorial on installing SonarQube using Docker

Table of contents 1. Pull the image 1.1 Pull the ...

Q&A: Differences between XML and HTML

Q: I don’t know what is the difference between xml...

Install Apple Mac OS X in VMWare12 Graphic Tutorial

1. Introduction: Because my friend wanted to lear...

Detailed explanation of Promises in JavaScript

Table of contents Basic usage of Promise: 1. Crea...

About React Native unable to link to the simulator

React Native can develop iOS and Android native a...

Difference between HTML ReadOnly and Enabled

The TextBox with the ReadOnly attribute will be di...