public class GenericWhereCondition extends WhereCondition<GenericWhereCondition>
| 限定符和类型 | 字段和说明 |
|---|---|
protected Map<String,TableAliasMapping> |
aliasTableMap
TODO 把这个抽成一个类,用来管理别名和表的映射关系
别名-表映射
1、** 表示如果没有别名则使用该表
2、*** 表示如果有没有别名都强制使用该表
|
protected StringBuilder |
condition |
protected String |
dataSourceName |
protected boolean |
isFirstBuild |
protected ParameterBinder |
parameterBinder |
protected SqlExecuteType |
sqlExecuteType |
protected Version |
version |
| 构造器和说明 |
|---|
GenericWhereCondition(Version version,
Map<String,TableAliasMapping> aliasTableMap,
String dataSourceName) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitandEqualTo, andExists, andGreaterThan, andGreaterThanOrEqualTo, andIn, andLessThan, andLessThanOrEqualTo, andNotEqualTo, andNotExists, andNotIn, orEqualTo, orExists, orGreaterThan, orGreaterThanOrEqualTo, orIn, orLessThan, orLessThanOrEqualTo, orNotEqualTo, orNotExists, orNotInandBetween, andBetween, andBetween, andCondition, andEqualTo, andEqualTo, andEqualTo, andEqualTo, andEqualTo, andFindInSet, andFindInSet, andFindInSet, andFunction, andGreaterThan, andGreaterThan, andGreaterThan, andGreaterThan, andGreaterThan, andGreaterThanOrEqualTo, andGreaterThanOrEqualTo, andGreaterThanOrEqualTo, andGreaterThanOrEqualTo, andIn, andIn, andIn, andIsNotNull, andIsNotNull, andIsNotNull, andIsNull, andIsNull, andIsNull, andLessThan, andLessThan, andLessThan, andLessThan, andLessThanOrEqualTo, andLessThanOrEqualTo, andLessThanOrEqualTo, andLessThanOrEqualTo, andLike, andLike, andMatches, andMatches, andNotBetween, andNotBetween, andNotEqualTo, andNotEqualTo, andNotEqualTo, andNotEqualTo, andNotEqualTo, andNotIn, andNotIn, andNotLike, andNotLike, limit, limit, orBetween, orBetween, orBetween, orCondition, orEqualTo, orEqualTo, orEqualTo, orEqualTo, orEqualTo, orFindInSet, orFindInSet, orFindInSet, orFunction, orGreaterThan, orGreaterThan, orGreaterThan, orGreaterThan, orGreaterThan, orGreaterThanOrEqualTo, orGreaterThanOrEqualTo, orGreaterThanOrEqualTo, orGreaterThanOrEqualTo, orIn, orIn, orIsNotNull, orIsNotNull, orIsNotNull, orIsNull, orIsNull, orIsNull, orLessThan, orLessThan, orLessThan, orLessThan, orLessThanOrEqualTo, orLessThanOrEqualTo, orLessThanOrEqualTo, orLessThanOrEqualTo, orLike, orLike, orMatches, orMatches, orNotBetween, orNotBetween, orNotEqualTo, orNotEqualTo, orNotEqualTo, orNotEqualTo, orNotEqualTo, orNotIn, orNotIn, orNotLike, orNotLike, selfprotected final Version version
protected final Map<String,TableAliasMapping> aliasTableMap
protected final StringBuilder condition
protected final ParameterBinder parameterBinder
protected String dataSourceName
protected boolean isFirstBuild
protected SqlExecuteType sqlExecuteType
public GenericWhereCondition(Version version, Map<String,TableAliasMapping> aliasTableMap, String dataSourceName)
public <T,F> GenericWhereCondition andEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public GenericWhereCondition andEqualTo(Object value, ColumFunction columFunction)
public <T,F> GenericWhereCondition orEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public GenericWhereCondition orEqualTo(Object value, ColumFunction columFunction)
public <T,F> GenericWhereCondition andNotEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orNotEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andGreaterThan(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orGreaterThan(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andGreaterThanOrEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orGreaterThanOrEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andLessThan(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orLessThan(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andLessThanOrEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orLessThanOrEqualTo(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andIn(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orIn(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andNotIn(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orNotIn(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andMatches(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orMatches(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andFindInSet(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition orFindInSet(Fn<T,F> fn, ColumFunction columFunction)
public <T,F> GenericWhereCondition andEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition orEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition andNotEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition orNotEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition andGreaterThan(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition orGreaterThan(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition andGreaterThanOrEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition orGreaterThanOrEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition andLessThan(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition orLessThan(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition andLessThanOrEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition orLessThanOrEqualTo(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套查询构造器public <T,F> GenericWhereCondition andIn(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套子查询构造器public <T,F> GenericWhereCondition orIn(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套子查询构造器public <T,F> GenericWhereCondition andNotIn(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套子查询构造器public <T,F> GenericWhereCondition orNotIn(Fn<T,F> fn, Consumer<AbstractColumnReference> nestedSelect)
NestedConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数nestedSelect - 嵌套子查询构造器public GenericWhereCondition andExists(Consumer<AbstractColumnReference> nestedSelect)
NestedConditionnestedSelect - 嵌套子查询构造器public GenericWhereCondition orExists(Consumer<AbstractColumnReference> nestedSelect)
NestedConditionnestedSelect - 嵌套子查询构造器public GenericWhereCondition andNotExists(Consumer<AbstractColumnReference> nestedSelect)
NestedConditionnestedSelect - 嵌套子查询构造器public GenericWhereCondition orNotExists(Consumer<AbstractColumnReference> nestedSelect)
NestedConditionnestedSelect - 嵌套子查询构造器public GenericWhereCondition andCondition(Consumer<GenericWhereCondition> nestedCondition)
Condition
该方法允许将一组条件作为当前条件的子条件进行添加,并且将它们合并为一个结果。
其中传入的 Consumer 对象接受一个 Condition 实例,
用于设置嵌套的条件组合。
例如:
condition.andCondition(nestedCondition -> {
nestedCondition.andEqualTo(SomeClass::getA, 1);
nestedCondition.orCondition(innerCondition -> {
innerCondition.andEqualTo(SomeClass::getB, 2);
innerCondition.orEqualTo(SomeClass::getC, 2);
});
});
public GenericWhereCondition orCondition(Consumer<GenericWhereCondition> nestedCondition)
ConditionnestedCondition - 用于配置嵌套条件的 Consumer 对象GenericWhereCondition 实例,以便实现链式调用Condition.andCondition(Consumer)public GenericWhereCondition andFunction(ColumFunction columFunction)
Condition该方法将指定的列函数条件与当前条件通过 AND 逻辑运算符连接,形成一个新的复合条件。 适用于需要多个条件同时满足的查询场景。
示例:查询指定的点是否包含在其中
List<LocationEntity> list = sqlContext.select()
.allColumn()
.from(LocationEntity.class)
.where(whereCondition -> whereCondition.andFunction(new Contains(LocationEntity::getArea, new Point(5, 5))))
.fetch()
.toList();
System.out.println(list.size());
columFunction - 要与当前条件通过 AND 连接的列函数条件,不能为空。
该参数通常表示对数据库列的某种操作或计算(例如 SUM、AVG 等)。Condition 实例,以便实现链式调用public GenericWhereCondition orFunction(ColumFunction columFunction)
Condition该方法将指定的列函数条件与当前条件通过 OR 逻辑运算符连接,形成一个新的复合条件。 适用于需要多个条件中至少一个满足的查询场景。
columFunction - 要与当前条件通过 OR 连接的列函数条件,不能为空。
该参数通常表示对数据库列的某种操作或计算(例如 MAX、MIN 等)。Condition 实例,以便实现链式调用public <T,F> GenericWhereCondition andEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition andEqualTo(Column column, Object value)
Conditioncolumn - 列对象value - 匹配的值public GenericWhereCondition andEqualTo(Column column, Column column2)
Conditioncolumn - 左侧列对象column2 - 右侧列对象public <T1,T2,F> GenericWhereCondition andEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
Condition
on.andEqualTo(Student::getClassId, Class::getId);
这将会生成 SQL 中的 "ON Student.classId = Class.id" 条件。T1 - 第一个实体类类型T2 - 第二个实体类类型F - 字段类型field1 - 第一个字段,来自第一个实体类field2 - 第二个字段,来自第二个实体类Condition 实例,以便实现链式调用public GenericWhereCondition andEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition orEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition orEqualTo(Column column, Object value)
public GenericWhereCondition orEqualTo(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition orEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition orEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition andNotEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition andNotEqualTo(Column column, Object value)
public GenericWhereCondition andNotEqualTo(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition andNotEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition andNotEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition orNotEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition orNotEqualTo(Column column, Object value)
public GenericWhereCondition orNotEqualTo(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition orNotEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition orNotEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition andIsNull(Fn<T,F> fn)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数public GenericWhereCondition andIsNull(Column column)
public GenericWhereCondition andIsNull(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition orIsNull(Fn<T,F> fn)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数public GenericWhereCondition orIsNull(ColumFunction columFunction, Object value)
public GenericWhereCondition orIsNull(Column column)
public <T,F> GenericWhereCondition andIsNotNull(Fn<T,F> fn)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数public GenericWhereCondition andIsNotNull(ColumFunction columFunction, Object value)
public GenericWhereCondition andIsNotNull(Column column)
public <T,F> GenericWhereCondition orIsNotNull(Fn<T,F> fn)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数public GenericWhereCondition orIsNotNull(ColumFunction columFunction, Object value)
public GenericWhereCondition orIsNotNull(Column column)
public <T,F> GenericWhereCondition andGreaterThan(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition andGreaterThan(Column column, Object value)
public GenericWhereCondition andGreaterThan(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition andGreaterThan(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition andGreaterThan(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition orGreaterThan(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition orGreaterThan(Column column, Object value)
public GenericWhereCondition orGreaterThan(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition orGreaterThan(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition orGreaterThan(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition andGreaterThanOrEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition andGreaterThanOrEqualTo(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition andGreaterThanOrEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition andGreaterThanOrEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition orGreaterThanOrEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition orGreaterThanOrEqualTo(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition orGreaterThanOrEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition orGreaterThanOrEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition andLessThan(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition andLessThan(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition andLessThan(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition andLessThan(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition orLessThan(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition orLessThan(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition orLessThan(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition orLessThan(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition andLessThanOrEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition andLessThanOrEqualTo(Column column, Column column2)
public GenericWhereCondition andLessThanOrEqualTo(ColumFunction columFunction, Object value)
public <T1,T2,F> GenericWhereCondition andLessThanOrEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public <T,F> GenericWhereCondition orLessThanOrEqualTo(Fn<T,F> fn, Object value)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数value - 匹配的值public GenericWhereCondition orLessThanOrEqualTo(Column column, Column column2)
public <T1,T2,F> GenericWhereCondition orLessThanOrEqualTo(Fn<T1,F> field1, Fn<T2,F> field2)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取第一个字段值的函数field2 - 用于获取第二个字段值的函数Condition 实例public GenericWhereCondition orLessThanOrEqualTo(ColumFunction columFunction, Object value)
public <T,F> GenericWhereCondition andIn(Fn<T,F> fn, Iterable<?> values)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数values - 匹配的值集合public GenericWhereCondition andIn(Column column, Iterable<?> values)
public GenericWhereCondition andIn(ColumFunction columFunction, Iterable<?> values)
public <T,F> GenericWhereCondition orIn(Fn<T,F> fn, Iterable<?> values)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数values - 匹配的值集合public GenericWhereCondition orIn(ColumFunction columFunction, Iterable<?> values)
public <T,F> GenericWhereCondition andNotIn(Fn<T,F> fn, Iterable<?> values)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数values - 匹配的值集合public GenericWhereCondition andNotIn(ColumFunction columFunction, Iterable<?> values)
public <T,F> GenericWhereCondition orNotIn(Fn<T,F> fn, Iterable<?> values)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数values - 匹配的值集合public GenericWhereCondition orNotIn(ColumFunction columFunction, Iterable<?> values)
public <T,F> GenericWhereCondition andBetween(Fn<T,F> fn, Object start, Object end)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数start - 范围起始值end - 范围结束值public GenericWhereCondition andBetween(Column column, Object start, Object end)
public <T1,T2,F> GenericWhereCondition andBetween(Fn<T1,F> field1, Fn<T2,F> startField, Fn<T2,F> endField)
Condition该方法用于构建一个 BETWEEN 连接条件,将指定字段的值与起始值和结束值之间的范围进行比较。 在调用此方法时,可以传入一个用于获取字段值的函数,以及两个用于获取起始值和结束值的函数。 这将生成一个 BETWEEN 条件,将其与当前条件组合使用。
例如,假设有两个表 `Order` 和 `Product`,可以使用此方法将 `Order` 表的某个字段与 `Product` 表中的起始和结束字段之间的范围进行比较:
condition.andBetween(
Order::getOrderDate, // Order 表的字段
Product::getStartDate, // Product 表中的起始字段
Product::getEndDate // Product 表中的结束字段
);
这将生成类似于以下 SQL 条件:
Order.orderDate BETWEEN Product.startDate AND Product.endDate
T1 - 实体类类型1,表示第一个表的实体类T2 - 实体类类型2,表示第二个表的实体类F - 字段类型,表示字段的数据类型field1 - 用于获取字段值的函数,表示要进行 BETWEEN 比较的字段startField - 用于获取起始值的函数,表示范围的起始值endField - 用于获取结束值的函数,表示范围的结束值Condition 实例,以便实现链式调用public <T,F> GenericWhereCondition orBetween(Fn<T,F> fn, Object start, Object end)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数start - 范围起始值end - 范围结束值public GenericWhereCondition orBetween(Column column, Object start, Object end)
public <T1,T2,F> GenericWhereCondition orBetween(Fn<T1,F> field1, Fn<T2,F> startField, Fn<T2,F> endField)
ConditionT1 - 实体类类型1T2 - 实体类类型2F - 字段类型field1 - 用于获取字段值的函数startField - 用于获取起始值的函数endField - 用于获取结束值的函数Condition 实例Condition.andBetween(Fn, Fn, Fn)public <T,F> GenericWhereCondition andNotBetween(Fn<T,F> fn, Object start, Object end)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数start - 范围起始值end - 范围结束值public GenericWhereCondition andNotBetween(Column column, Object start, Object end)
public <T,F> GenericWhereCondition orNotBetween(Fn<T,F> fn, Object start, Object end)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数start - 范围起始值end - 范围结束值public GenericWhereCondition orNotBetween(Column column, Object start, Object end)
public <T,F> GenericWhereCondition andLike(Fn<T,F> fn, String pattern)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数pattern - 匹配的模式(如 SQL 的 LIKE 子句)public GenericWhereCondition andLike(Column column, Object value)
public <T,F> GenericWhereCondition orLike(Fn<T,F> fn, String pattern)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数pattern - 匹配的模式(如 SQL 的 LIKE 子句)public GenericWhereCondition orLike(Column column, Object value)
public <T,F> GenericWhereCondition andNotLike(Fn<T,F> fn, String pattern)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数pattern - 匹配的模式(如 SQL 的 LIKE 子句)public GenericWhereCondition andNotLike(Column column, Object value)
public <T,F> GenericWhereCondition orNotLike(Fn<T,F> fn, String pattern)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数pattern - 匹配的模式(如 SQL 的 LIKE 子句)public GenericWhereCondition orNotLike(Column column, Object value)
public <T,F> GenericWhereCondition andMatches(Fn<T,F> fn, String regex)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数regex - 正则表达式模式public GenericWhereCondition andMatches(Column column, String regex)
public <T,F> GenericWhereCondition orMatches(Fn<T,F> fn, String regex)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数regex - 正则表达式模式public GenericWhereCondition orMatches(Column column, String regex)
public <T,F> GenericWhereCondition andFindInSet(Fn<T,F> fn, Object item)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数item - 指定的项目public GenericWhereCondition andFindInSet(Column column, Object value)
public <T,F> GenericWhereCondition orFindInSet(Fn<T,F> fn, Object item)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数item - 指定的项目public GenericWhereCondition orFindInSet(Column column, Object value)
public <T,F> GenericWhereCondition andFindInSet(Fn<T,F> fn, Object item, String separator)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数item - 指定的项目separator - 分隔符public <T,F> GenericWhereCondition orFindInSet(Fn<T,F> fn, Object item, String separator)
ConditionT - 实体类类型F - 字段类型fn - 用于获取字段值的函数item - 指定的项目separator - 分隔符public GenericWhereCondition limit(int offset, int limit)
Conditionoffset - 需要跳过的行数limit - 返回的最大行数public GenericWhereCondition limit(int limit)
Conditionlimit - 返回的最大行数public String getWhereConditionSyntax()
public ParameterBinder getParameterBinder()
protected String logicalOperatorType(LogicalOperatorType logicalOperatorType)
protected String logicalOperatorType(LogicalOperatorType logicalOperatorType, SqlDialect sqlDialect)
public GenericWhereCondition andEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition andEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition orEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andNotEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition andNotEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orNotEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition orNotEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andGreaterThan(AggregateFunction function, Object value)
public GenericWhereCondition andGreaterThan(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orGreaterThan(AggregateFunction function, Object value)
public GenericWhereCondition orGreaterThan(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andGreaterThanOrEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition andGreaterThanOrEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orGreaterThanOrEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition orGreaterThanOrEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andLessThan(AggregateFunction function, Object value)
public GenericWhereCondition andLessThan(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orLessThan(AggregateFunction function, Object value)
public GenericWhereCondition orLessThan(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andLessThanOrEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition andLessThanOrEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orLessThanOrEqualTo(AggregateFunction function, Object value)
public GenericWhereCondition orLessThanOrEqualTo(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andIn(AggregateFunction function, Iterable<?> values)
public GenericWhereCondition andIn(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orIn(AggregateFunction function, Iterable<?> values)
public GenericWhereCondition orIn(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andNotIn(AggregateFunction function, Iterable<?> values)
public GenericWhereCondition andNotIn(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition orNotIn(AggregateFunction function, Iterable<?> values)
public GenericWhereCondition orNotIn(AggregateFunction function, Consumer<AbstractColumnReference> nestedSelect)
public GenericWhereCondition andBetween(AggregateFunction function, Object start, Object end)
public GenericWhereCondition orBetween(AggregateFunction function, Object start, Object end)
public GenericWhereCondition andNotBetween(AggregateFunction function, Object start, Object end)
public GenericWhereCondition orNotBetween(AggregateFunction function, Object start, Object end)
public GenericWhereCondition sql(String sql)
WhereCondition该方法用于插入无法通过已有 API 构建的原始 SQL 条件,常用于处理复杂逻辑、数据库函数、自定义分区截取等情况。
注意: 该方法不做 SQL 安全校验,需确保传入字符串是安全且语法正确的 SQL 片段。
sql 在类中 WhereCondition<GenericWhereCondition>sql - 自定义 SQL 条件表达式,例如 "and age > 18", "or row_num = 1", "exists (...)"protected String executeFunctionToString(AggregateFunction function)
protected SqlDialect sqlDialect()
public void setSqlExecuteType(SqlExecuteType sqlExecuteType)
Copyright © 2024–2025 Dynamic-SQL. All rights reserved.