@Inherited @Retention(value=RUNTIME) @Target(value={FIELD,ANNOTATION_TYPE}) public @interface TableField
| 限定符和类型 | 可选元素和说明 | ||
|---|---|---|---|
SqlCondition |
condition
生成where时使用的条件
|
||
boolean |
exist
是否为数据库表字段
默认 true 存在,false 不存在
|
||
FieldStrategy |
insertStrategy
字段验证策略之 insert: 当insert操作时,该字段拼接insert语句时的策略
IGNORED: 直接拼接 insert into table_a(column) values (#{columnProperty});
NOT_NULL: insert into table_a( booleanmapUnderlineCase
生成ResultMap时是否自动映射大写到下划线,仅当没有配置字段名称时才生效
| ||
boolean |
select
是否加入select查询列
|
||
String |
update
字段 update set 部分注入, 该注解优于 el 注解使用
例1:@TableField(.. , update="%s+1") 其中 %s 会填充为字段
输出 SQL 为:update 表 set 字段=字段+1 where ...
|
||
FieldStrategy |
updateStrategy
字段验证策略之 update: 当更新操作时,该字段拼接set语句时的策略
IGNORED: 直接拼接 update table_a set column=#{columnProperty}, 属性为null/空string都会被set进去
NOT_NULL: update table_a set Stringvalue
数据库字段值
不需要配置该值的情况:
当
mapUnderlineCase() 为 true 时,
(mp下默认是true,mybatis默认是false), 数据库字段值.replace("_","").toUpperCase() == 实体属性名.toUpperCase()
当 mapUnderlineCase() 为 false 时,
数据库字段值.toUpperCase() == 实体属性名.toUpperCase() | ||
FieldStrategy |
whereStrategy
| ||
WrapType |
wrapType
表名前后包装,例:`table_name`
|
public abstract String value
不需要配置该值的情况:
mapUnderlineCase() 为 true 时,
(mp下默认是true,mybatis默认是false), 数据库字段值.replace("_","").toUpperCase() == 实体属性名.toUpperCase() mapUnderlineCase() 为 false 时,
数据库字段值.toUpperCase() == 实体属性名.toUpperCase() public abstract String update
例1:@TableField(.. , update="%s+1") 其中 %s 会填充为字段 输出 SQL 为:update 表 set 字段=字段+1 where ...
例2:@TableField(.. , update="now()") 使用数据库时间 输出 SQL 为:update 表 set 字段=now() where ...
public abstract FieldStrategy insertStrategy
IGNORED: 直接拼接 insert into table_a(column) values (#{columnProperty});
NOT_NULL: insert into table_a(
public abstract FieldStrategy updateStrategy
IGNORED: 直接拼接 update table_a set column=#{columnProperty}, 属性为null/空string都会被set进去
NOT_NULL: update table_a set
public abstract FieldStrategy whereStrategy
IGNORED: 直接拼接 column=#{columnProperty}
NOT_NULL:
public abstract boolean mapUnderlineCase
public abstract WrapType wrapType
public abstract String wrap
public abstract SqlCondition condition
Copyright © 2024. All rights reserved.