天天看點

Mybatis-Plus常用注解

@TableName:表名注解

Mybatis-Plus常用注解

@TableId:主鍵注解

Mybatis-Plus常用注解

@IdType:主鍵注解

Mybatis-Plus常用注解

@TableFieId:字段注解(非主鍵)

屬性

類型

必須指定

預設值

描述

value

String

""

資料庫字段名

el

映射為原生#{...}邏輯,相當于寫在xml

裡的#{...}部分

exist

boolean

true

是否為資料庫表字段

condition

字段 <code>where</code> 實體查詢比較條件,有值設定則按設定的值為準,沒有則為預設全局的 <code>%s=#{%s}</code>

update

字段 <code>update set</code> 部分注入, 例如:update="%s+1":表示更新時會set version=version+1(該屬性優先級高于 <code>el</code> 屬性)

insertStrategy

Enum

N

DEFAULT

舉例:NOT_NULL: <code>insert into table_a(&lt;if test="columnProperty != null"&gt;column&lt;/if&gt;) values (&lt;if test="columnProperty != null"&gt;#{columnProperty}&lt;/if&gt;)</code>

updateStrategy

舉例:IGNORED: <code>update table_a set column=#{columnProperty}</code>

whereStrategy

舉例:NOT_EMPTY: <code>where &lt;if test="columnProperty != null and columnProperty!=''"&gt;column=#{columnProperty}&lt;/if&gt;</code>

fill

FieldFill.DEFAULT

字段自動填充政策

select

是否進行 select 查詢

keepGlobalFormat

false

是否保持使用全局的 format 進行處理

jdbcType

JdbcType

JdbcType.UNDEFINED

JDBC類型 (該預設值不代表會按照該值生效)

typeHandler

Class&lt;? extends TypeHandler&gt;

UnknownTypeHandler.class

類型處理器 (該預設值不代表會按照該值生效)

numericScale

指定小數點後保留的位數

@FieIdStrategy:字段注解(非主鍵)

Mybatis-Plus常用注解

@FieIdFill:字段注解(非主鍵)

Mybatis-Plus常用注解

@Version:樂觀鎖注解、标記@Version在字段上

@EnumValue:通枚舉類注解(注解在枚舉字段上)

@TableLogic:表字段邏輯處理注解(邏輯删除)

Mybatis-Plus常用注解

@KeySequence:序列主鍵政策oracle

Mybatis-Plus常用注解
Mybatis-Plus常用注解