public class JoinWrapper<T,J> extends SupportJoinLambdaWrapper<T,JoinWrapper<T,J>> implements com.baomidou.mybatisplus.core.conditions.query.Query<JoinWrapper<T,J>,T,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>>
| 限定符和类型 | 字段和说明 |
|---|---|
private List<HavingBuild> |
havingBuildList
having 条件列表
|
private boolean |
logicDeleteIsApplyJoin
逻辑删除是否拼接到Join后面
true 拼接
false 拼接到join 后面
|
private ManyToManySelectBuild |
manyToManySelectBuild
多对多构建
|
private OneToOneSelectBuild |
oneToOneSelectBuild
一对一构建
|
private List<com.baomidou.mybatisplus.core.conditions.SharedString> |
sqlJoin
join字段
|
private JoinLambdaWrapper<J> |
wrapper |
aliasMap, orderByBuildList, sunQueryListcustomAliasMap, fieldMappingList, hasDistinct, joinSql, manyToManySelectBuildList, masterLogicDelete, masterTableAlias, notDefaultSelectAll, oneToOneSelectBuildList, sqlSelect| 构造器和说明 |
|---|
JoinWrapper(Class<T> entityClass,
JoinLambdaWrapper<J> wrapper,
boolean logicDelete)
不建议直接 new 该实例,使用 Wrappers.lambdaQuery(entity)
|
JoinWrapper(Class<T> entityClass,
JoinLambdaWrapper<J> wrapper,
String alias)
不建议直接 new 该实例,使用 Wrappers.lambdaQuery(entity)
|
JoinWrapper(Class<T> entityClass,
JoinLambdaWrapper<J> wrapper,
String alias,
boolean logicDelete)
不建议直接 new 该实例,使用 Wrappers.lambdaQuery(entity)
|
JoinWrapper(JoinLambdaWrapper<J> wrapper)
不建议直接 new 该实例,使用 Wrappers.lambdaQuery(entity)
|
JoinWrapper(T entity,
Class<T> entityClass,
List<com.baomidou.mybatisplus.core.conditions.SharedString> sqlSelect,
AtomicInteger paramNameSeq,
Map<String,Object> paramNameValuePairs,
com.baomidou.mybatisplus.core.conditions.segments.MergeSegments mergeSegments,
Map<Class<?>,String> aliasMap,
com.baomidou.mybatisplus.core.conditions.SharedString lastSql,
com.baomidou.mybatisplus.core.conditions.SharedString sqlComment,
com.baomidou.mybatisplus.core.conditions.SharedString sqlFirst)
不建议直接 new 该实例,使用 Wrappers.lambdaQuery(...)
|
JoinWrapper(T entity,
JoinLambdaWrapper<J> wrapper)
不建议直接 new 该实例,使用 Wrappers.lambdaQuery(entity)
|
JoinWrapper(T entity,
JoinLambdaWrapper<J> wrapper,
String alias) |
JoinWrapper(T entity,
JoinLambdaWrapper<J> wrapper,
String alias,
boolean logicDelete) |
| 限定符和类型 | 方法和说明 |
|---|---|
private String |
appendLogicDeleteCondition(String joinSql,
com.baomidou.mybatisplus.core.metadata.TableInfo tableInfo,
String tableAlias)
添加逻辑删除条件
|
private <P> List<FieldMapping> |
buildField(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column,
java.util.function.Consumer<ColumnsBuilder<T>> consumer) |
private <F> void |
buildJoinSql(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField,
com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField,
SqlExcerpt sqlExcerpt)
构建join SQL - 优化后的方法
|
void |
clear() |
JoinLambdaWrapper<J> |
end()
join 句子结束
|
private String |
getMasterTableAlias(Class<?> joinTableClass,
Class<?> masterTableClass)
获取主表别名
|
String |
getSqlSelect() |
List<com.baomidou.mybatisplus.core.conditions.SharedString> |
getSqlSelectList() |
JoinWrapper<T,J> |
having(boolean condition,
String sqlHaving,
Object... params)
重写父类having语句,存入参数值,传递到JoinLambdaWrapper中,避免重复添加
|
<F> JoinWrapper<T,J> |
innerJoin(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField,
com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField)
join 处理
|
protected JoinWrapper<T,J> |
instance()
用于生成嵌套 sql
故 sqlSelect 不向下传递
|
<X> JoinWrapper<T,J> |
joinAnd(int index,
java.util.function.Consumer<JoinWrapper<T,J>> consumer) |
JoinWrapper<T,J> |
joinAnd(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> field,
Object val,
int index)
join 后的拼的条件
|
<X> JoinWrapper<T,J> |
joinAnd(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> field,
com.baomidou.mybatisplus.core.toolkit.support.SFunction<X,Object> val,
int index) |
<F> JoinWrapper<T,J> |
leftJoin(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField,
com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField)
left join 处理
|
<P> JoinWrapper<T,J> |
manyToManySelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column,
Class<?> manyToManyClass)
多对多方法,使用该方法,可以不需要指定列,默认查询全部字段
|
<P> JoinWrapper<T,J> |
manyToManySelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column,
Class<?> manyToManyClass,
java.util.function.Consumer<ColumnsBuilder<T>> consumer) |
<P> JoinWrapper<T,J> |
oneToOneSelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column,
Class<?> modelClass)
一对一方法,使用该方法,可以不需要指定列,默认查询全部字段
|
<P> JoinWrapper<T,J> |
oneToOneSelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column,
java.util.function.Consumer<ColumnsBuilder<T>> consumer) |
<F> JoinWrapper<T,J> |
rightJoin(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField,
com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField)
right join 处理
|
JoinWrapper<T,J> |
select(Class<T> entityClass,
java.util.function.Predicate<com.baomidou.mybatisplus.core.metadata.TableFieldInfo> predicate)
过滤查询的字段信息(主键除外!)
|
JoinWrapper<T,J> |
select(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>... columns)
SELECT 部分 SQL 设置
|
private boolean |
shouldApplyLogicDelete(Class<?> tableClass)
判断是否应用逻辑删除
|
addCondition, between, changeQueryWrapper, columnsToString, columnsToString, columnsToString, columnToString, columnToString, columnToStringNoAlias, eq, ge, getAlias, getAlias, getAliasAndField, getAliasAndField, getColumn, getConditionR, getEntityOrMasterClass, getSelectColumn, getTableClass, gt, initNeed, le, lt, ne, notBetween, orderBy, orderBySql, selectAll, selectAll, selectAs, selectAs, selectAs, selectAs, selectSunQuery, selectSunQuery, setAliasaddObjConditions, addObjConditions, distinct, executeQuery, getAliasAndField, getFuncKeyWord, getJoinSql, getTableFieldInfoByFieldName, getTableFieldInfoByFieldName, masterLogicDelete, readWrapperInfo, setFieldMappingList, setFuncKeyWordaddCondition, addNestedCondition, allEq, allEq, and, and, appendSqlSegments, apply, between, clone, columnSqlInjectFilter, columnsToString, columnToSqlSegment, comment, eq, exists, first, formatParam, formatSqlMaybeWithParam, func, ge, geSql, getEntity, getEntityClass, getExpression, getParamAlias, getParamNameValuePairs, getSqlComment, getSqlFirst, getSqlSegment, groupBy, groupBy, groupBy, gt, gtSql, in, in, inExpression, inExpression, inSql, isNotNull, isNull, isUseAnnotationOrderBy, last, le, leSql, like, likeLeft, likeRight, likeValue, lt, ltSql, maybeDo, ne, nested, not, not, notBetween, notExists, notIn, notIn, notInSql, notLike, notLikeLeft, notLikeRight, or, or, orderBy, orderBy, orderBy, setEntity, setEntityClass, setParamAliasgetCustomSqlSegment, getSqlSet, getTargetSql, isEmptyOfEntity, isEmptyOfNormal, isEmptyOfWhere, nonEmptyOfEntity, nonEmptyOfNormal, nonEmptyOfWhereequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitorderByAsc, orderByAsc, orderByDesc, orderByDesc, orderBySqlbetween, eq, ge, gt, le, lt, ne, notBetweenbetweenIfNull, eqIfNull, geIfNull, gtIfNull, leIfNull, likeIfNull, likeLeftIfNull, likeRightIfNull, ltIfNull, neIfNull, notBetweenIfNull, notLikeIfNull, notLikeLeftIfNull, notLikeRightIfNullallEq, allEq, allEq, allEq, allEq, allEq, between, between, eq, eq, ge, ge, gt, gt, le, le, like, like, likeLeft, likeLeft, likeRight, likeRight, lt, lt, ne, ne, notBetween, notBetween, notLike, notLike, notLikeLeft, notLikeLeft, notLikeRight, notLikeRightapply, comment, exists, first, last, notExists, orfunc, geSql, groupBy, groupBy, groupBy, gtSql, having, in, in, inSql, isNotNull, isNull, leSql, ltSql, notIn, notIn, notInSql, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByAsc, orderByDesc, orderByDesc, orderByDesc, orderByDesc, orderByDesc, orderByDescprivate JoinLambdaWrapper<J> wrapper
private List<com.baomidou.mybatisplus.core.conditions.SharedString> sqlJoin
private List<HavingBuild> havingBuildList
private OneToOneSelectBuild oneToOneSelectBuild
private ManyToManySelectBuild manyToManySelectBuild
private boolean logicDeleteIsApplyJoin
JoinWrapper(JoinLambdaWrapper<J> wrapper)
JoinWrapper(T entity, JoinLambdaWrapper<J> wrapper)
JoinWrapper(T entity, JoinLambdaWrapper<J> wrapper, String alias)
JoinWrapper(T entity, JoinLambdaWrapper<J> wrapper, String alias, boolean logicDelete)
JoinWrapper(Class<T> entityClass, JoinLambdaWrapper<J> wrapper, String alias)
JoinWrapper(Class<T> entityClass, JoinLambdaWrapper<J> wrapper, String alias, boolean logicDelete)
JoinWrapper(Class<T> entityClass, JoinLambdaWrapper<J> wrapper, boolean logicDelete)
JoinWrapper(T entity, Class<T> entityClass, List<com.baomidou.mybatisplus.core.conditions.SharedString> sqlSelect, AtomicInteger paramNameSeq, Map<String,Object> paramNameValuePairs, com.baomidou.mybatisplus.core.conditions.segments.MergeSegments mergeSegments, Map<Class<?>,String> aliasMap, com.baomidou.mybatisplus.core.conditions.SharedString lastSql, com.baomidou.mybatisplus.core.conditions.SharedString sqlComment, com.baomidou.mybatisplus.core.conditions.SharedString sqlFirst)
@SafeVarargs public final JoinWrapper<T,J> select(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>... columns)
select 在接口中 com.baomidou.mybatisplus.core.conditions.query.Query<JoinWrapper<T,J>,T,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>>columns - 查询字段public <P> JoinWrapper<T,J> manyToManySelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column, Class<?> manyToManyClass)
column - 列public <P> JoinWrapper<T,J> manyToManySelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column, Class<?> manyToManyClass, java.util.function.Consumer<ColumnsBuilder<T>> consumer)
public <P> JoinWrapper<T,J> oneToOneSelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column, Class<?> modelClass)
column - 列public <P> JoinWrapper<T,J> oneToOneSelect(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column, java.util.function.Consumer<ColumnsBuilder<T>> consumer)
private <P> List<FieldMapping> buildField(com.baomidou.mybatisplus.core.toolkit.support.SFunction<P,?> column, java.util.function.Consumer<ColumnsBuilder<T>> consumer)
public JoinWrapper<T,J> select(Class<T> entityClass, java.util.function.Predicate<com.baomidou.mybatisplus.core.metadata.TableFieldInfo> predicate)
例1: 只要 java 字段名以 "test" 开头的 -> select(i -> i.getProperty().startsWith("test"))
例2: 只要 java 字段属性是 CharSequence 类型的 -> select(TableFieldInfoExt::isCharSequence)
例3: 只要 java 字段没有填充策略的 -> select(i -> i.getFieldFill() == FieldFill.DEFAULT)
例4: 要全部字段 -> select(i -> true)
例5: 只要主键字段 -> select(i -> false)
select 在接口中 com.baomidou.mybatisplus.core.conditions.query.Query<JoinWrapper<T,J>,T,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>>predicate - 过滤方式public String getSqlSelect()
public List<com.baomidou.mybatisplus.core.conditions.SharedString> getSqlSelectList()
protected JoinWrapper<T,J> instance()
故 sqlSelect 不向下传递
instance 在类中 com.baomidou.mybatisplus.core.conditions.AbstractWrapper<T,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>,JoinWrapper<T,J>>public void clear()
clear 在类中 com.baomidou.mybatisplus.core.conditions.AbstractWrapper<T,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>,JoinWrapper<T,J>>public <F> JoinWrapper<T,J> leftJoin(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField, com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField)
joinTableField - 需要关联的表字段masterTableField - 主表关联表字段public <F> JoinWrapper<T,J> rightJoin(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField, com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField)
joinTableField - 需要关联的表字段masterTableField - 主表关联表字段public <F> JoinWrapper<T,J> innerJoin(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField, com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField)
joinTableField - 需要关联的表字段masterTableField - 主表关联表字段public JoinWrapper<T,J> having(boolean condition, String sqlHaving, Object... params)
having 在接口中 com.baomidou.mybatisplus.core.conditions.interfaces.Func<JoinWrapper<T,J>,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>>having 在类中 com.baomidou.mybatisplus.core.conditions.AbstractWrapper<T,com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,?>,JoinWrapper<T,J>>condition - 是否执行sqlHaving - 执行SQLparams - 参数public JoinWrapper<T,J> joinAnd(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> field, Object val, int index)
field - 字段val - 值index - 索引,对应的第几个join 从0 开始计算public <X> JoinWrapper<T,J> joinAnd(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> field, com.baomidou.mybatisplus.core.toolkit.support.SFunction<X,Object> val, int index)
public <X> JoinWrapper<T,J> joinAnd(int index, java.util.function.Consumer<JoinWrapper<T,J>> consumer)
private <F> void buildJoinSql(com.baomidou.mybatisplus.core.toolkit.support.SFunction<T,Object> joinTableField, com.baomidou.mybatisplus.core.toolkit.support.SFunction<F,Object> masterTableField, SqlExcerpt sqlExcerpt)
private String getMasterTableAlias(Class<?> joinTableClass, Class<?> masterTableClass)
private boolean shouldApplyLogicDelete(Class<?> tableClass)
private String appendLogicDeleteCondition(String joinSql, com.baomidou.mybatisplus.core.metadata.TableInfo tableInfo, String tableAlias)
public JoinLambdaWrapper<J> end()
Copyright © 2025. All rights reserved.