public class ColumnReference extends AbstractColumnReference
selectSpecification| 构造器和说明 |
|---|
ColumnReference(SelectSpecification selectSpecification) |
| 限定符和类型 | 方法和说明 |
|---|---|
AbstractColumnReference |
allColumn()
选择所有列。
|
AbstractColumnReference |
allColumn(Class<?> tableClass)
选择特定表的所有列。
|
AbstractColumnReference |
allColumn(String tableAlias)
选择指定表别名的所有列。
|
ColumnReference |
column(AbstractColumFunction iColumFunction)
添加一个函数列到查询中。
|
AbstractColumnReference |
column(AbstractColumFunction iColumFunction,
String columnAlias)
添加一个带别名的函数列到查询中。
|
<T,F> ColumnReference |
column(FieldFn<T,F> fn,
String columnAlias)
添加一个列到查询中,并设置列别名。
|
<T,F> ColumnReference |
column(Fn<T,F> fn)
添加一个列到查询中,使用方法引用指定字段。
|
AbstractColumnReference |
column(NumberColumn numberColumn)
添加一个数字列到查询中。
|
AbstractColumnReference |
column(SelectDsl nestedSelect,
String columnAlias)
添加一个嵌套查询列到当前查询中。
|
<T,F> ColumnReference |
column(String tableAlias,
FieldFn<T,F> fn)
添加一个带有表别名的列到查询中。
|
<T,F> ColumnReference |
column(String tableAlias,
FieldFn<T,F> fn,
String columnAlias)
添加一个带有表别名和列别名的列到查询中。
|
AbstractColumnReference |
column(String tableAlias,
String columnName)
添加一个自定义列到查询中。
|
AbstractColumnReference |
column(String tableAlias,
String columnName,
String columnAlias)
添加一个带有别名的自定义列到查询中。
|
AbstractColumnReference |
column(WindowsFunction windowsFunction,
Consumer<Over> over,
String columnAlias)
添加一个窗口函数列到查询中。
|
AbstractColumnReference |
columnReference(AbstractColumnReference columnReference)
已过时。
|
AbstractColumnReference |
distinct()
添加去重关键字(DISTINCT)到查询中。
|
<T> TableRelation<T> |
from(Class<T> tableClass)
设置查询的主表。
|
<T> TableRelation<T> |
from(Class<T> tableClass,
String alias)
设置带有别名的主表。
|
TableRelation<?> |
from(CteTable cteTable)
设置公共表表达式(CTE)为主表。
|
TableRelation<?> |
from(SelectDsl nestedSelect,
String selectAlias)
设置嵌套查询作为主表。
|
<T> TableRelation<T> |
from(Supplier<TableFunction> tableFunction,
String tableAlias)
设置表函数作为主表。
|
TableRelation<?> |
fromUnion(SelectDsl[] selectDsl,
String selectAlias)
构建 UNION 查询的表关系。
|
TableRelation<?> |
fromUnionAll(SelectDsl[] selectDsl,
String selectAlias)
构建 UNION ALL 查询的表关系。
|
<T,F> AbstractColumnReference |
ignoreColumn(Fn<T,F> fn)
显式忽略一个列,使其不参与查询结果。
|
AbstractColumnReference |
nestedColumn(KeyMapping<?,?> keyMapping,
Function<AbstractColumnReference,AbstractColumnReference> valueMapper,
String targetProperty)
执行“直接嵌套集合或对象”的列引用构建逻辑。
|
static AbstractColumnReference |
withColumns()
构建一个查询列的引用集合,用于定义查询中的多个列。
|
allColumn, allColumn, allColumn, collectionColumn, collectionColumn, column, column, column, column, column, column, column, column, column, column, column, column, column, distinct, getSelectSpecification, ignoreColumn, includeColumns, includeColumns, nestedColumnpublic ColumnReference(SelectSpecification selectSpecification)
public AbstractColumnReference distinct()
AbstractColumnReference该方法会将 `DISTINCT` 关键字应用到当前查询的列选择中,确保返回结果中不包含重复记录。
distinct 在类中 AbstractColumnReferencepublic static AbstractColumnReference withColumns()
此方法创建并返回一个 `AbstractColumnReference` 实例, 允许通过链式调用添加列或嵌套的列引用。
示例:
AbstractColumnReference columnReference = ColumnReference.withColumns()
.column(Product::getProductId)
.column(Product::getProductName)
.columnReference(nestedColumnReference());
AbstractColumnReference 对象public <T,F> ColumnReference column(Fn<T,F> fn)
AbstractColumnReference通过方法引用(`Fn`)选择实体类中的特定字段,添加到查询列列表中。
column 在类中 AbstractColumnReferenceT - 表对应的实体类类型F - 字段的类型fn - 映射函数,用于引用实体类中的字段public <T,F> AbstractColumnReference ignoreColumn(Fn<T,F> fn)
AbstractColumnReference显式忽略一个列,使其不参与查询结果。
常用于在已经选择了多个列的情况下,排除掉其中某些不需要的列。
ignoreColumn 在类中 AbstractColumnReferenceT - 表对应的实体类类型F - 字段的类型fn - 字段引用函数,通常为实体类的 getter 方法引用public <T,F> ColumnReference column(String tableAlias, FieldFn<T,F> fn)
AbstractColumnReference通过指定表别名和方法引用选择字段,适用于多表查询场景。
column 在类中 AbstractColumnReferenceT - 表对应的实体类类型F - 字段的类型tableAlias - 表的别名,用于区分同名字段fn - 映射函数,用于引用实体类中的字段public <T,F> ColumnReference column(FieldFn<T,F> fn, String columnAlias)
AbstractColumnReference通过方法引用选择字段,并为列指定别名,便于结果映射或查询结果识别。
column 在类中 AbstractColumnReferenceT - 表对应的实体类类型F - 字段的类型fn - 映射函数,用于引用实体类中的字段columnAlias - 列的别名public <T,F> ColumnReference column(String tableAlias, FieldFn<T,F> fn, String columnAlias)
AbstractColumnReference适用于多表查询场景,通过表别名和列别名明确指定字段。
column 在类中 AbstractColumnReferenceT - 表对应的实体类类型F - 字段的类型tableAlias - 表的别名fn - 映射函数,用于引用实体类中的字段columnAlias - 列的别名public AbstractColumnReference column(String tableAlias, String columnName)
AbstractColumnReference通过指定表别名和列名,适合手动定义列或非实体字段。
column 在类中 AbstractColumnReferencetableAlias - 表的别名columnName - 列名public AbstractColumnReference column(String tableAlias, String columnName, String columnAlias)
AbstractColumnReference通过表别名、列名和列别名定义自定义字段。
column 在类中 AbstractColumnReferencetableAlias - 表的别名columnName - 列名columnAlias - 列的别名public ColumnReference column(AbstractColumFunction iColumFunction)
AbstractColumnReference通过 AbstractColumFunction 定义聚合函数或标量函数(如 `SUM`、`ROUND`)。
column 在类中 AbstractColumnReferenceiColumFunction - 函数列的定义public AbstractColumnReference column(AbstractColumFunction iColumFunction, String columnAlias)
AbstractColumnReference为函数列指定别名,便于结果映射。
column 在类中 AbstractColumnReferenceiColumFunction - 函数列的定义columnAlias - 列的别名public AbstractColumnReference column(NumberColumn numberColumn)
AbstractColumnReference通过 NumberColumn 定义数字相关的列操作。
column 在类中 AbstractColumnReferencenumberColumn - 数字列对象public AbstractColumnReference column(WindowsFunction windowsFunction, Consumer<Over> over, String columnAlias)
AbstractColumnReference通过 WindowsFunction 和 Over 定义窗口函数(如 `RANK`、`LAG`),并指定窗口定义。
column 在类中 AbstractColumnReferencewindowsFunction - 窗口函数实例over - 窗口定义的消费者,用于配置排序或分区columnAlias - 列的别名public AbstractColumnReference column(SelectDsl nestedSelect, String columnAlias)
AbstractColumnReference通过嵌套查询定义一个子查询列,适合复杂查询场景。
column 在类中 AbstractColumnReferencenestedSelect - 嵌套查询的定义,接受一个消费者来构建子查询columnAlias - 列的别名public AbstractColumnReference nestedColumn(KeyMapping<?,?> keyMapping, Function<AbstractColumnReference,AbstractColumnReference> valueMapper, String targetProperty)
AbstractColumnReference该方法用于构建复杂对象结构的字段映射,例如:
方法会根据 keyMapping 确定父子对象的关联关系,通过 valueMapper 对嵌套列引用进行加工, 最终将结果绑定到 targetProperty 指定的实体字段上。
nestedColumn 在类中 AbstractColumnReferencekeyMapping - 主键/外键映射关系,用于确定嵌套对象或集合的关联方式valueMapper - 对嵌套列引用进行加工的函数,可用于构建集合、对象或进一步嵌套targetProperty - 目标属性名称(实体类字段名),用于将嵌套结果写入对应对象或集合@Deprecated public AbstractColumnReference columnReference(AbstractColumnReference columnReference)
AbstractColumnReference注意:该方法已过时,将在未来版本中移除,建议使用 AbstractColumnReference.includeColumns(AbstractColumnReference) 替代。
columnReference 在类中 AbstractColumnReferencecolumnReference - 另一个列引用实例public AbstractColumnReference allColumn()
AbstractColumnReference添加当前查询的所有列(无条件选择),适用于选择表中的全部字段。
allColumn 在类中 AbstractColumnReferencepublic AbstractColumnReference allColumn(Class<?> tableClass)
AbstractColumnReference根据指定的实体类选择表中的所有列。
allColumn 在类中 AbstractColumnReferencetableClass - 表对应的实体类public AbstractColumnReference allColumn(String tableAlias)
AbstractColumnReference根据表别名选择对应的所有列,适用于多表查询。
allColumn 在类中 AbstractColumnReferencetableAlias - 表别名public <T> TableRelation<T> from(Class<T> tableClass)
AbstractColumnReference指定实体类作为主表,初始化查询的数据源。
from 在类中 AbstractColumnReferenceT - 表对应的实体类类型tableClass - 表对应的实体类TableRelation 对象,用于定义表关系public <T> TableRelation<T> from(Class<T> tableClass, String alias)
AbstractColumnReference指定实体类和表别名作为主表,适用于多表或别名查询。
from 在类中 AbstractColumnReferenceT - 表对应的实体类类型tableClass - 表对应的实体类alias - 表别名TableRelation 对象,用于定义表关系public <T> TableRelation<T> from(Supplier<TableFunction> tableFunction, String tableAlias)
AbstractColumnReference通过 TableFunction 和别名定义动态表,适合复杂查询。
from 在类中 AbstractColumnReferenceT - 表对应的实体类类型tableFunction - 表函数的供应商tableAlias - 表别名TableRelation 对象,用于定义表关系public TableRelation<?> from(CteTable cteTable)
AbstractColumnReference使用 CteTable 定义 CTE 作为查询的数据源。
from 在类中 AbstractColumnReferencecteTable - 公共表表达式对象TableRelation 对象,用于定义表关系public TableRelation<?> from(SelectDsl nestedSelect, String selectAlias)
AbstractColumnReference通过嵌套查询定义子查询作为主表,适合复杂数据源。
from 在类中 AbstractColumnReferencenestedSelect - 嵌套查询的定义,接受一个消费者来构建子查询selectAlias - 嵌套查询的别名TableRelation 对象,用于定义表关系public TableRelation<?> fromUnion(SelectDsl[] selectDsl, String selectAlias)
AbstractColumnReference该方法用于将多个子查询(SELECT DSL)通过 UNION 组合成一个虚拟表, 并在 FROM 子句中以指定别名引用。例如:
FROM (
SELECT ... FROM ...
UNION
SELECT ... FROM ...
UNION
SELECT ... FROM ...
) AS t
可能的使用场景:
fromUnion 在类中 AbstractColumnReferenceselectDsl - 多个子查询的 DSL 数组,每个元素代表一个 SELECT 语句selectAlias - UNION 结果集在 FROM 子句中的别名TableRelation 对象,用于定义表关系public TableRelation<?> fromUnionAll(SelectDsl[] selectDsl, String selectAlias)
AbstractColumnReference该方法用于将多个子查询(SELECT DSL)通过 UNION ALL 组合成一个虚拟表, 并在 FROM 子句中以指定别名引用。例如:
FROM (
SELECT ... FROM ...
UNION ALL
SELECT ... FROM ...
UNION ALL
SELECT ... FROM ...
) AS t
可能的使用场景:
fromUnionAll 在类中 AbstractColumnReferenceselectDsl - 多个子查询的 DSL 数组,每个元素代表一个 SELECT 语句selectAlias - UNION ALL 结果集在 FROM 子句中的别名TableRelation 对象,用于定义表关系Copyright © 2024–2026 Dynamic-SQL. All rights reserved.