Class DtoSelector<TypeOverride>

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.
  • 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 DTO
      ormTable - the ORM table
      tableRegistry - the table registry
      classFieldAccessorCache - the class field accessor cache
      dtoConstructor - the DTO constructor
      databaseProvider - the database provider
      aliasGenerator - the alias generator
      litebridgeContext - the litebridge context
      node - the current query node
  • Method Details

    • createSelectSpec

      protected DtoSelectSpec createSelectSpec(AliasGenerator aliasGenerator)
      Specified by:
      createSelectSpec in class org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
    • select

      public DtoFromClauseTerminal<TypeOverride> select(ExpressionSpec... expressionSpecs)
      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

      public DtoSelector<TypeOverride> withNode(QueryNode node)
      Description copied from class: org.litebridge.orm.api.select.impl.AbstractSelector
      Sets the current node to the specified query node.
      Specified by:
      withNode in class org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
      Parameters:
      node - the new query node
      Returns:
      the selector instance
    • oneOrNull

      public @Nullable TypeOverride oneOrNull()
      Description copied from interface: SelectTerminal
      Executes the query and expects exactly one result.
      Specified by:
      oneOrNull in interface SelectTerminal<TypeOverride>
      Specified by:
      oneOrNull in class org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
      Returns:
      the single result, or null when no row matches
    • firstOrNull

      public @Nullable TypeOverride firstOrNull()
      Description copied from interface: SelectTerminal
      Executes the query and returns the first row if present.
      Specified by:
      firstOrNull in interface SelectTerminal<TypeOverride>
      Specified by:
      firstOrNull in class org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
      Returns:
      the first result, or null when no row matches
    • list

      public List<TypeOverride> list()
      Description copied from interface: SelectTerminal
      Executes the query and materializes all results into a List.
      Specified by:
      list in interface SelectTerminal<TypeOverride>
      Specified by:
      list in class org.litebridge.orm.api.select.impl.AbstractSelector<TypeOverride,DtoSelectSpec>
      Returns:
      list of all matching results (possibly empty)
    • classFieldAccessorCache

      public ClassFieldAccessorCache classFieldAccessorCache()
      Returns the class field accessor cache.
      Returns:
      the class field accessor cache
    • table

      public Table table()
      Returns the table associated with this selector.
      Returns:
      the table
    • createSelectFieldSpecs

      public List<ExpressionSpec> createSelectFieldSpecs(String[] fields)
      Creates select field specifications for the given fields.
      Parameters:
      fields - the field names
      Returns:
      the list of expression specifications