Class AbstractWrapper<T,R,Children extends AbstractWrapper<T,R,Children>>
- All Implemented Interfaces:
Compare<Children,,R> Func<Children,,R> Join<Children>,Nested<Children,,Children> ISqlSegment,Serializable
- Direct Known Subclasses:
AbstractLambdaWrapper,QueryWrapper,UpdateWrapper
- Since:
- 2017-05-26
- Author:
- hubin miemie HCL
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MergeSegmentsprotected SharedStringprotected SharedString其他protected AtomicInteger必要度量protected SharedStringSQL注释protected SharedStringSQL起始语句protected final Children占位符 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ChildrenaddCondition(boolean condition, R column, SqlKeyword sqlKeyword, Object val) 普通查询条件protected ChildrenaddNestedCondition(boolean condition, Consumer<Children> consumer) 多重嵌套查询条件<V> ChildrenallEq(boolean condition, BiPredicate<R, V> filter, Map<R, V> params, boolean null2IsNull) 字段过滤接口,传入多参数时允许对参数进行过滤<V> Childrenmap 所有非空属性等于 =protected Childrenand(boolean condition) 内部自用AND 嵌套protected voidappendSqlSegments(ISqlSegment... sqlSegments) 添加 where 片段拼接 sqlBETWEEN 值1 AND 值2voidclear()条件清空clone()protected StringcolumnsToString(List<R> columns) 多字段转换为逗号 "," 分割字符串protected StringcolumnsToString(R... columns) 获取 columnNamesprotected StringcolumnToMapping(R column) protected final ColumnSegmentcolumnToSqlSegment(R column) 获取 columnNameprotected StringcolumnToString(R column) 获取 columnNamesql 注释(会拼接在 sql 的最后面)等于 =eqOrIsNull(boolean condition, R column, Object val) 等于 = ,值为 null 时自动转为 IS NULL字段 EQ ( sql语句 )拼接 EXISTS ( sql语句 )sql 起始句(会拼接在SQL语句的起始处)protected final StringformatParam(String mapping, Object param) 处理入参protected final StringformatSqlMaybeWithParam(String sqlStr, Object... params) 格式化 sql消费函数大于等于 >=字段 >= ( sql语句 )实体对象(子类实现)获取 MergeSegmentsSQL 片段分组:GROUP BY 字段, ...分组:GROUP BY 字段, ...分组:GROUP BY 字段, ...分组:GROUP BY 字段, ...大于 >字段 > ( sql语句 )HAVING ( sql语句 )字段 IN (v0, v1, ...)in(boolean condition, R column, Collection<?> coll) 字段 IN (value.get(0), value.get(1), ...)protected ISqlSegmentinExpression(Object[] values) 获取in表达式 包含括号protected ISqlSegmentinExpression(Object[] values, String mapping) protected ISqlSegmentinExpression(Collection<?> value) 获取in表达式 包含括号protected ISqlSegmentinExpression(Collection<?> value, String mapping) protected voidinitNeed()必要的初始化字段 IN ( sql语句 )protected abstract Childreninstance()子类返回一个自己的新对象字段 IS NOT NULL字段 IS NULLboolean是否使用默认注解OrderBy排序无视优化规则直接拼接到 sql 的最后(有sql注入的风险,请谨慎使用)小于等于 <=字段 invalid input: '<'= ( sql语句 )LIKE '%值%'LIKE '%值'LIKE '值%'protected ChildrenlikeValue(boolean condition, SqlKeyword keyword, R column, Object val, SqlLike sqlLike) 内部自用小于 <字段 < ( sql语句 )protected final ChildrenmaybeDo(boolean condition, AbstractWrapper.DoSomething something) 函数化的做事不等于 <>正常嵌套 不带 AND 或者 ORprotected Childrennot(boolean condition) 内部自用not嵌套notBetween(boolean condition, R column, Object val1, Object val2) NOT BETWEEN 值1 AND 值2拼接 NOT EXISTS ( sql语句 )字段 NOT IN (v0, v1, ...)notIn(boolean condition, R column, Collection<?> coll) 字段 NOT IN (value.get(0), value.get(1), ...)字段 NOT IN ( sql语句 )NOT LIKE '%值%'notLikeLeft(boolean condition, R column, Object val) NOT LIKE '%值'notLikeRight(boolean condition, R column, Object val) NOT LIKE '值%'protected voidonParamAliasChanged(String oldParamAlias, String paramAlias) 参数别名变化后的扩展处理or(boolean condition) 拼接 OROR 嵌套排序:ORDER BY 字段, ...排序:ORDER BY 字段, ...排序:ORDER BY 字段, ...排序:ORDER BY 字段, ...setEntityClass(Class<T> entityClass) setParamAlias(String paramAlias) 参数别名设置,初始化时优先设置该值Methods inherited from class com.baomidou.mybatisplus.core.conditions.Wrapper
getCustomSqlSegment, getSqlSelect, getSqlSet, getTargetSql, isEmptyOfEntity, isEmptyOfNormal, isEmptyOfWhere, isNonEmptyOfEntity, isNonEmptyOfNormal, isNonEmptyOfWhere, nonEmptyOfEntity, nonEmptyOfNormal, nonEmptyOfWhereMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.baomidou.mybatisplus.core.conditions.interfaces.Compare
allEq, allEq, allEq, allEq, between, eq, eqOrIsNull, ge, gt, le, like, likeLeft, likeRight, lt, ne, notBetween, notLike, notLikeLeft, notLikeRightMethods inherited from interface com.baomidou.mybatisplus.core.conditions.interfaces.Func
eqSql, func, geSql, groupBy, groupBy, groupBy, gtSql, having, in, in, inSql, isNotNull, isNull, leSql, ltSql, notIn, notIn, notInSql, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByDesc, orderByDesc, orderByDesc, orderByDesc, orderByDesc, orderByDesc, orderByDesc
-
Field Details
-
typedThis
占位符 -
paramNameSeq
必要度量 -
paramNameValuePairs
-
paramAlias
其他 -
lastSql
-
sqlComment
SQL注释 -
sqlFirst
SQL起始语句 -
expression
-
-
Constructor Details
-
AbstractWrapper
public AbstractWrapper()
-
-
Method Details
-
getEntity
Description copied from class:Wrapper实体对象(子类实现) -
setEntity
-
getEntityClass
-
setEntityClass
-
allEq
Description copied from interface:Comparemap 所有非空属性等于 = -
allEq
public <V> Children allEq(boolean condition, BiPredicate<R, V> filter, Map<R, V> params, boolean null2IsNull) Description copied from interface:Compare字段过滤接口,传入多参数时允许对参数进行过滤 -
eq
Description copied from interface:Compare等于 = -
eqOrIsNull
Description copied from interface:Compare等于 = ,值为 null 时自动转为 IS NULL- Specified by:
eqOrIsNullin interfaceCompare<T,R> - Parameters:
condition- 执行条件column- 字段val- 值- Returns:
- children
-
ne
Description copied from interface:Compare不等于 <> -
gt
Description copied from interface:Compare大于 > -
ge
Description copied from interface:Compare大于等于 >= -
lt
Description copied from interface:Compare小于 < -
le
Description copied from interface:Compare小于等于 <= -
like
Description copied from interface:CompareLIKE '%值%' -
notLike
Description copied from interface:CompareNOT LIKE '%值%' -
likeLeft
Description copied from interface:CompareLIKE '%值' -
likeRight
Description copied from interface:CompareLIKE '值%' -
notLikeLeft
Description copied from interface:CompareNOT LIKE '%值'- Specified by:
notLikeLeftin interfaceCompare<T,R> - Parameters:
condition- 执行条件column- 字段val- 值- Returns:
- children
-
notLikeRight
Description copied from interface:CompareNOT LIKE '值%'- Specified by:
notLikeRightin interfaceCompare<T,R> - Parameters:
condition- 执行条件column- 字段val- 值- Returns:
- children
-
between
Description copied from interface:CompareBETWEEN 值1 AND 值2 -
notBetween
Description copied from interface:CompareNOT BETWEEN 值1 AND 值2- Specified by:
notBetweenin interfaceCompare<T,R> - Parameters:
condition- 执行条件column- 字段val1- 值1val2- 值2- Returns:
- children
-
and
Description copied from interface:NestedAND 嵌套例: and(i -> i.eq("name", "李白").ne("status", "活着"))
-
or
Description copied from interface:NestedOR 嵌套例: or(i -> i.eq("name", "李白").ne("status", "活着"))
-
nested
Description copied from interface:Nested正常嵌套 不带 AND 或者 OR例: nested(i -> i.eq("name", "李白").ne("status", "活着"))
-
not
Description copied from interface:Nestednot嵌套例: not(i -> i.eq("name", "李白").ne("status", "活着"))
-
or
Description copied from interface:Join拼接 OR -
apply
Description copied from interface:Join拼接 sql!! 会有 sql 注入风险 !!
例1: apply("id = 1")
例2: apply("date_format(dateColumn,'%Y-%m-%d') = '2008-08-08'")
例3: apply("date_format(dateColumn,'%Y-%m-%d') = {0}", LocalDate.now())
例4: apply("type={0,javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler}", "待处理字符串")
-
last
Description copied from interface:Join无视优化规则直接拼接到 sql 的最后(有sql注入的风险,请谨慎使用)例: last("limit 1")
注意只能调用一次,多次调用以最后一次为准
-
comment
Description copied from interface:Joinsql 注释(会拼接在 sql 的最后面)自3.5.6开始,默认不处理转义字符,如有需要,调用
StringEscape.escapeRawString(String) -
first
Description copied from interface:Joinsql 起始句(会拼接在SQL语句的起始处)自3.5.6开始,默认不处理转义字符,如有需要,调用
StringEscape.escapeRawString(String) -
exists
Description copied from interface:Join拼接 EXISTS ( sql语句 )!! sql 注入方法 !!
例: exists("select id from table where age = 1")
-
notExists
Description copied from interface:Join拼接 NOT EXISTS ( sql语句 )!! sql 注入方法 !!
例: notExists("select id from table where age = 1")
-
isNull
Description copied from interface:Func字段 IS NULL例: isNull(true, "name")
-
isNotNull
Description copied from interface:Func字段 IS NOT NULL例: isNotNull(true, "name")
-
in
Description copied from interface:Func字段 IN (value.get(0), value.get(1), ...)例: in(true, "id", Arrays.asList(1, 2, 3, 4, 5))
- 注意!当集合为 空或null 时, sql会拼接为:WHERE (字段名 IN ()), 执行时报错
- 若要在特定条件下不拼接, 可在 condition 条件中判断
-
in
Description copied from interface:Func字段 IN (v0, v1, ...)例: in(true, "id", 1, 2, 3, 4, 5)
- 注意!当数组为 空或null 时, sql会拼接为:WHERE (字段名 IN ()), 执行时报错
- 若要在特定条件下不拼接, 可在 condition 条件中判断
-
notIn
Description copied from interface:Func字段 NOT IN (value.get(0), value.get(1), ...)例: notIn(true, "id", Arrays.asList(1, 2, 3, 4, 5))
- 注意!当集合为 空或null 时, sql会拼接为:WHERE (字段名 NOT IN ()), 执行时报错
- 若要在特定条件下不拼接, 可在 condition 条件中判断
-
notIn
Description copied from interface:Func字段 NOT IN (v0, v1, ...)例: notIn(true, "id", 1, 2, 3, 4, 5)
- 注意!当数组为 空或null 时, sql会拼接为:WHERE (字段名 NOT IN ()), 执行时报错
- 若要在特定条件下不拼接, 可在 condition 条件中判断
-
eqSql
Description copied from interface:Func字段 EQ ( sql语句 )!! sql 注入方式的 eq 方法 !!
例1: eqSql("id", "1")
例2: eqSql("id", "select MAX(id) from table")
-
inSql
Description copied from interface:Func字段 IN ( sql语句 )!! sql 注入方式的 in 方法 !!
例1: inSql(true, "id", "1")
例2: inSql(true, "id", "select id from table where id < 3")
-
gtSql
Description copied from interface:Func字段 > ( sql语句 )例1: gtSql(true, "id", "1")
例1: gtSql(true, "id", "select id from table where name = 'JunJun'")
-
geSql
Description copied from interface:Func字段 >= ( sql语句 )例1: geSql(true, "id", "1")
例1: geSql(true, "id", "select id from table where name = 'JunJun'")
-
ltSql
Description copied from interface:Func字段 < ( sql语句 )例1: ltSql(true, "id", "1")
例1: ltSql(true , "id", "select id from table where name = 'JunJun'")
-
leSql
Description copied from interface:Func字段 invalid input: '<'= ( sql语句 )例1: leSql(true, "id", "1")
例1: leSql(true ,"id", "select id from table where name = 'JunJun'")
-
notInSql
Description copied from interface:Func字段 NOT IN ( sql语句 )!! sql 注入方式的 not in 方法 !!
例1: notInSql(true, "id", "1, 2, 3, 4, 5, 6")
例2: notInSql(true, "id", "select id from table where id < 3")
-
groupBy
Description copied from interface:Func分组:GROUP BY 字段, ...例: groupBy(true, "id", "name")
-
groupBy
Description copied from interface:Func分组:GROUP BY 字段, ...例: groupBy(true, "id", Arrays.asList("name"))
-
doGroupBy
-
doOrderBy
-
orderBy
Description copied from interface:Func排序:ORDER BY 字段, ... -
orderBy
Description copied from interface:Func排序:ORDER BY 字段, ... -
groupBy
Description copied from interface:Func分组:GROUP BY 字段, ...例: groupBy(true, "id")
-
groupBy
Description copied from interface:Func分组:GROUP BY 字段, ...例: groupBy(true, Arrays.asList("id", "name"))
-
orderBy
Description copied from interface:Func排序:ORDER BY 字段, ...例: orderBy(true, "id")
-
orderBy
Description copied from interface:Func排序:ORDER BY 字段, ...例: orderBy(true, Arrays.asList("id", "name"))
-
having
Description copied from interface:FuncHAVING ( sql语句 )例1: having(true, "sum(age) > 10")
例2: having(true, "sum(age) > {0}", 10)
-
func
Description copied from interface:Func消费函数 -
not
内部自用NOT 关键词
-
and
内部自用拼接 AND
-
likeValue
protected Children likeValue(boolean condition, SqlKeyword keyword, R column, Object val, SqlLike sqlLike) 内部自用拼接 LIKE 以及 值
-
addCondition
普通查询条件- Parameters:
condition- 是否执行column- 属性sqlKeyword- SQL 关键词val- 条件值
-
addNestedCondition
多重嵌套查询条件- Parameters:
condition- 查询条件值
-
instance
子类返回一个自己的新对象 -
formatSqlMaybeWithParam
格式化 sql支持 "{0}" 这种,或者 "sql {0} sql" 这种 也支持 "sql {0,javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler} sql" 这种
- Parameters:
sqlStr- 可能是sql片段params- 参数- Returns:
- sql片段
-
formatParam
处理入参- Parameters:
mapping- 例如: "javaType=int,jdbcType=NUMERIC,typeHandler=xxx.xxx.MyTypeHandler" 这种param- 参数- Returns:
- value
-
maybeDo
函数化的做事- Parameters:
condition- 做不做something- 做什么- Returns:
- Children
-
inExpression
获取in表达式 包含括号- Parameters:
value- 集合
-
inExpression
-
inExpression
获取in表达式 包含括号- Parameters:
values- 数组
-
inExpression
-
initNeed
protected void initNeed()必要的初始化 -
clear
public void clear()Description copied from class:Wrapper条件清空 -
appendSqlSegments
添加 where 片段- Parameters:
sqlSegments- ISqlSegment 数组
-
isUseAnnotationOrderBy
public boolean isUseAnnotationOrderBy()是否使用默认注解OrderBy排序- Returns:
- true 使用 false 不使用
-
getSqlSegment
Description copied from interface:ISqlSegmentSQL 片段- Specified by:
getSqlSegmentin interfaceISqlSegment
-
getSqlComment
- Overrides:
getSqlCommentin classWrapper<T>
-
getSqlFirst
- Overrides:
getSqlFirstin classWrapper<T>
-
getExpression
Description copied from class:Wrapper获取 MergeSegments- Specified by:
getExpressionin classWrapper<T>
-
getParamAlias
-
setParamAlias
参数别名设置,初始化时优先设置该值- Parameters:
paramAlias- 参数别名- Returns:
- Children
-
onParamAliasChanged
参数别名变化后的扩展处理- Parameters:
oldParamAlias- 原参数别名paramAlias- 新参数别名
-
columnToSqlSegment
获取 columnName -
columnToString
获取 columnName -
columnToMapping
-
columnsToString
获取 columnNames -
columnsToString
多字段转换为逗号 "," 分割字符串- Parameters:
columns- 多字段
-
clone
-
getParamNameValuePairs
-