Tag Archives: Mybatisplus ignores mapped fields

[How to Fix]Mybatisplus ignores mapped fields

In the development, we may encounter that mybatisplus uses entity class attribute for SQL operation. The entity has this attribute, but the database table does not have this field (that is, entity class attribute is not a database table field). If you don’t handle it, you will report an error.

FIRE

@TableName: Database Table Related

@TableId: table primary key identifier

@TableField: table field identifier

@TableLogic: Table field logical processing annotation (logical deletion

)
Solution

@TableField(exists = false): indicates that the property is not a database table field, but is required to be used.
 
@TableField(exists = true): indicates that the property is a database table field.

After adding this annotation to the attributes of the entity class, this field will not map to the database.

   @TableField(exist = false)
    private String deptName;