Mybatis-Plus plug-in Mybatis the entity class annotate articles

The main comment to comment on the entity classes:

@TableName(value = …)

When the database name and the name of the entity class name is inconsistent or does not meet the hump, you need to specify the table name in this comment

@TableId(type = …)

Entity class attribute specifies the corresponding primary key, are the following:

// database ID of the self-energizing 
IdType.AUTO
 // the type of the primary key type is not set (default) 
IdType.NONE 
 / ** 
 * The user input ID 
 * <P> may be filled by the type register themselves automatically fill plug </ p> 
 * / 
IdType.INPUT 
/ * the following three types, only when the inserted object ID is empty, it is automatically populated. * / 
// globally unique ID (idWorker) 
IdType.ID_WORKER
 // 2. globally unique ID (the UUID) 
IdType.UUID
 // 3. globally unique string ID (idWorker string representation) 
IdType.ID_WORKER_STR

@TableField comment

1, is mainly used to solve the problem of field names and field names in the database does not match the entity class (database user_addr, field useraddr not hump)

2, the entity class attribute field in the table no problem

Common:

// to solve the fields in the database and the entity class field mismatch 
@TableField (value = "Age" )
 // used to solve some of the entity class field attribute data table but not 
@TableField (exist = to false )   // defaults to true

 

If not specified, the following exception occurs: BadSqlGrammarException

// do not return to the field queries, default true, and @TableId role failure when on the same field 
@TableField (the SELECT = false )

 

 

Guess you like

Origin www.cnblogs.com/Nickc/p/12001764.html