Entity class and database table field mapping

Mybatis – Plus is very convenient, compared with MyBatis, it has my favorite CRUD and conditional constructor, so that the amount of anti-human XML file code is greatly reduced, this article mainly records my usual encounter about entity class and database field corresponding problems, because the use of its own CRUD, So it’s a little different from mybatis

	private String newLocation;

    @TableField("homecity")
    private String homeCity;
Copy the code

Here are two fields from my POJO class. The newLocation property is automatically mapped to mybatis- Plus CRUD query

select new_location from XXX;
Copy the code

When a database field does not meet the default rules above, such as the homeCity property of the POJO class above, it is mapped to the column name of home_city, but the table FIELD I used was homeCity, not home_city. So you just specify it with @tableField (“homecity”).

How to use THE CRUD of Mybatis – Plus, how to write the detailed code, the official document only introduces the usage, I will write an article to tell you recently, if you can’t wait friends can private message me 😀