java.lang.Object
org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
org.litebridge.orm.api.dto.DtoSelector<TypeOverride>
- Type Parameters:
TypeOverride- the type of the DTO
- All Implemented Interfaces:
SelectTerminal<TypeOverride>
public final class DtoSelector<TypeOverride>
extends org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
Selector for DTOs.
-
Field Summary
Fields inherited from class org.litebridge.orm.api.select.impl.AbstractSelector
databaseProvider, dtoClass, litebridgeContext, node -
Constructor Summary
ConstructorsConstructorDescriptionDtoSelector(Class<TypeOverride> typeOverride, OrmTable ormTable, TableRegistry tableRegistry, ClassFieldAccessorCache classFieldAccessorCache, DtoConstructor dtoConstructor, TransactionalDatabaseProvider databaseProvider, AliasGenerator aliasGenerator, LitebridgeContext litebridgeContext, @Nullable QueryNode node) Creates a new DtoSelector. -
Method Summary
Modifier and TypeMethodDescriptionReturns the class field accessor cache.createSelectFieldSpecs(String[] fields) Creates select field specifications for the given fields.protected DtoSelectSpeccreateSelectSpec(AliasGenerator aliasGenerator) @Nullable TypeOverrideExecutes the query and returns the first row if present.list()Executes the query and materializes all results into aList.@Nullable TypeOverrideExecutes the query and expects exactly one result.select()Selects all fields of the DTO.select(ExpressionSpec... expressionSpecs) Selects specific fields.table()Returns the table associated with this selector.Sets the current node to the specified query node.Methods inherited from class org.litebridge.orm.api.select.impl.AbstractSelector
compile, executeQuery, executeQuery, executeQuery, first, firstOrThrow, firstOrThrow, litebridgeContext, node, one, oneOrThrow, oneOrThrow, stream, toSql
-
Constructor Details
-
DtoSelector
public DtoSelector(Class<TypeOverride> typeOverride, OrmTable ormTable, TableRegistry tableRegistry, ClassFieldAccessorCache classFieldAccessorCache, DtoConstructor dtoConstructor, TransactionalDatabaseProvider databaseProvider, AliasGenerator aliasGenerator, LitebridgeContext litebridgeContext, @Nullable QueryNode node) Creates a new DtoSelector.- Parameters:
typeOverride- the type of the DTOormTable- the ORM tabletableRegistry- the table registryclassFieldAccessorCache- the class field accessor cachedtoConstructor- the DTO constructordatabaseProvider- the database provideraliasGenerator- the alias generatorlitebridgeContext- the litebridge contextnode- the current query node
-
-
Method Details
-
createSelectSpec
- Specified by:
createSelectSpecin classorg.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
-
select
Selects specific fields.- Parameters:
expressionSpecs- the expression specifications to select- Returns:
- the from clause terminal
-
select
Selects all fields of the DTO.- Returns:
- the from clause terminal
-
withNode
Description copied from class:org.litebridge.orm.api.select.impl.AbstractSelectorSets the current node to the specified query node.- Specified by:
withNodein classorg.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec> - Parameters:
node- the new query node- Returns:
- the selector instance
-
oneOrNull
Description copied from interface:SelectTerminalExecutes the query and expects exactly one result.- Specified by:
oneOrNullin interfaceSelectTerminal<TypeOverride>- Specified by:
oneOrNullin classorg.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec> - Returns:
- the single result, or
nullwhen no row matches
-
firstOrNull
Description copied from interface:SelectTerminalExecutes the query and returns the first row if present.- Specified by:
firstOrNullin interfaceSelectTerminal<TypeOverride>- Specified by:
firstOrNullin classorg.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec> - Returns:
- the first result, or
nullwhen no row matches
-
list
Description copied from interface:SelectTerminalExecutes the query and materializes all results into aList.- Specified by:
listin interfaceSelectTerminal<TypeOverride>- Specified by:
listin classorg.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec> - Returns:
- list of all matching results (possibly empty)
-
classFieldAccessorCache
Returns the class field accessor cache.- Returns:
- the class field accessor cache
-
table
Returns the table associated with this selector.- Returns:
- the table
-
createSelectFieldSpecs
Creates select field specifications for the given fields.- Parameters:
fields- the field names- Returns:
- the list of expression specifications
-