Module litebridge.orm
Class DelegatingSelectTerminal<DTO>
java.lang.Object
org.litebridge.orm.api.select.impl.DelegatingSelectTerminal<DTO>
- Type Parameters:
DTO- the mapped DTO/entity type or row type
- All Implemented Interfaces:
SelectTerminal<DTO>
- Direct Known Subclasses:
FromClauseStart,FromClauseStartTypeOverride,LimitClauseTerminalImpl
Abstract terminal implementation delegating select execution methods to
SelectEngineTerminal.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final LitebridgeContextprotected @Nullable QueryNodeprotected final SelectEngineTerminal -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDelegatingSelectTerminal(@Nullable QueryNode node, SelectEngineTerminal selectEngineTerminal, LitebridgeContext litebridgeContext) Creates a newDelegatingSelectTerminalinstance.DelegatingSelectTerminal(SelectEngineTerminal selectEngineTerminal, Supplier<LitebridgeContext> litebridgeContextSupplier) -
Method Summary
Modifier and TypeMethodDescriptionfirst()Executes the query and returns the first row if present.@Nullable DTOExecutes the query and returns the first row if present, ornullif no row matches.Executes the query and returns the first row.firstOrThrow(Supplier<? extends X> exceptionSupplier) Executes the query and returns the first row.list()Executes the query and returns a list of results.protected LitebridgeContextprotected QueryNodenode()one()Executes the query and returns exactly one result.@Nullable DTOExecutes the query and returns exactly one result, ornullif no row matches.Executes the query and returns exactly one result.oneOrThrow(Supplier<? extends X> exceptionSupplier) Executes the query and returns exactly one result.stream()Executes the query and returns results as aStream.toSql()Generates SQL for the query without executing it.
-
Field Details
-
selectEngineTerminal
-
litebridgeContext
-
node
-
pendingNode
-
-
Constructor Details
-
DelegatingSelectTerminal
protected DelegatingSelectTerminal(@Nullable QueryNode node, SelectEngineTerminal selectEngineTerminal, LitebridgeContext litebridgeContext) Creates a newDelegatingSelectTerminalinstance.- Parameters:
node- the query nodeselectEngineTerminal- the terminal select enginelitebridgeContext- the Litebridge context
-
DelegatingSelectTerminal
public DelegatingSelectTerminal(SelectEngineTerminal selectEngineTerminal, Supplier<LitebridgeContext> litebridgeContextSupplier)
-
-
Method Details
-
one
Description copied from interface:SelectTerminalExecutes the query and returns exactly one result.The returned
Optionalis empty when no row matches. If more than one row matches, anNonUniqueResultExceptionis thrown.- Specified by:
onein interfaceSelectTerminal<DTO>- Returns:
- an
Optionalcontaining the single result, if present
-
oneOrNull
Description copied from interface:SelectTerminalExecutes the query and returns exactly one result, ornullif no row matches.If more than one row matches, an
NonUniqueResultExceptionis thrown.- Specified by:
oneOrNullin interfaceSelectTerminal<DTO>- Returns:
- the single result, or
nullwhen no row matches - Throws:
NonUniqueResultException- if more than one row matches
-
oneOrThrow
Description copied from interface:SelectTerminalExecutes the query and returns exactly one result.If no row matches, an
NoSuchElementExceptionis thrown. If more than one row matches, anNonUniqueResultExceptionis thrown.- Specified by:
oneOrThrowin interfaceSelectTerminal<DTO>- Returns:
- the single result
- Throws:
NoSuchElementException- if no row matches
-
oneOrThrow
Description copied from interface:SelectTerminalExecutes the query and returns exactly one result.If no row matches, the supplied exception is thrown. If more than one row matches, an
NonUniqueResultExceptionis thrown.- Specified by:
oneOrThrowin interfaceSelectTerminal<DTO>- Type Parameters:
X- exception type- Parameters:
exceptionSupplier- supplier used to create the exception to throw when the result is not exactly one row- Returns:
- the single result
- Throws:
X- if no row matches or more than one row matches
-
first
Description copied from interface:SelectTerminalExecutes the query and returns the first row if present.Unlike
SelectTerminal.one(), this method does not require uniqueness; if multiple rows match, only the first is returned (according to the effective ordering, if any).- Specified by:
firstin interfaceSelectTerminal<DTO>- Returns:
- an
Optionalwith the first result, if present
-
firstOrNull
Description copied from interface:SelectTerminalExecutes the query and returns the first row if present, ornullif no row matches.- Specified by:
firstOrNullin interfaceSelectTerminal<DTO>- Returns:
- the first result, or
nullif no row matches
-
firstOrThrow
Description copied from interface:SelectTerminalExecutes the query and returns the first row.If no row matches, an
NoSuchElementExceptionis thrown.- Specified by:
firstOrThrowin interfaceSelectTerminal<DTO>- Returns:
- the first result
- Throws:
NoSuchElementException- if no row matches
-
firstOrThrow
Description copied from interface:SelectTerminalExecutes the query and returns the first row.If no row matches, the supplied exception is thrown.
- Specified by:
firstOrThrowin interfaceSelectTerminal<DTO>- Type Parameters:
X- exception type- Parameters:
exceptionSupplier- supplier used to create the exception to throw when no row matches- Returns:
- the first result
- Throws:
X- if no row matches
-
stream
Description copied from interface:SelectTerminalExecutes the query and returns results as aStream.- Specified by:
streamin interfaceSelectTerminal<DTO>- Returns:
- a stream of results
-
list
Description copied from interface:SelectTerminalExecutes the query and returns a list of results.- Specified by:
listin interfaceSelectTerminal<DTO>- Returns:
- list of all matching results (possibly empty)
-
toSql
Description copied from interface:SelectTerminalGenerates SQL for the query without executing it.- Specified by:
toSqlin interfaceSelectTerminal<DTO>- Returns:
- The generated SQL, bind values and query metadata.
-
litebridgeContext
-
node
-