Command implementation objects.
This interface provides factory methods for instantiating various types of database commands
used in the Doma framework. Each method creates a specific type of command object that is
responsible for executing a corresponding Query object.
Implementations of this interface are responsible for creating the appropriate command objects based on the DAO method being executed. These command objects handle the execution of database operations (select, insert, update, delete, batch operations, etc.) and process the results.
The default implementations of these methods create standard command objects, but custom implementations can override these methods to provide specialized behavior or extended functionality for specific command types, such as custom transaction handling, logging, or performance monitoring.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <RESULT,ENTITY>
AggregateCommand<RESULT,ENTITY> createAggregateCommand(Method method, SelectQuery query, EntityType<ENTITY> entityType, StreamReducer<RESULT, ENTITY> resultReducer, AggregateStrategyType aggregateStrategyType) Creates anAggregateCommandobject for aggregating entities based on a specified query and strategy.default BatchDeleteCommandcreateBatchDeleteCommand(Method method, BatchDeleteQuery query) Creates aBatchDeleteCommandobject.default BatchInsertCommandcreateBatchInsertCommand(Method method, BatchInsertQuery query) Creates aBatchInsertCommandobject.default BatchUpdateCommandcreateBatchUpdateCommand(Method method, BatchUpdateQuery query) Creates aBatchUpdateCommandobject.default <RESULT> CreateCommand<RESULT>createCreateCommand(Method method, CreateQuery<RESULT> query) Creates aCreateCommandobject.default DeleteCommandcreateDeleteCommand(Method method, DeleteQuery query) Creates aDeleteCommandobject.default <RESULT> DeleteReturningCommand<RESULT>createDeleteReturningCommand(Method method, DeleteQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates aDeleteReturningCommandobject.default <RESULT> FunctionCommand<RESULT>createFunctionCommand(Method method, FunctionQuery<RESULT> query) Creates aFunctionCommandobject.default InsertCommandcreateInsertCommand(Method method, InsertQuery query) Creates anInsertCommandobject.default <RESULT> InsertReturningCommand<RESULT>createInsertReturningCommand(Method method, InsertQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates anInsertReturningCommandobject.default ProcedureCommandcreateProcedureCommand(Method method, ProcedureQuery query) Creates aProcedureCommandobject.default ScriptCommandcreateScriptCommand(Method method, ScriptQuery query) Creates aScriptCommandobject.default <RESULT> SelectCommand<RESULT>createSelectCommand(Method method, SelectQuery query, ResultSetHandler<RESULT> resultSetHandler) Creates aSelectCommandobject.default <RESULT> SqlProcessorCommand<RESULT>createSqlProcessorCommand(Method method, SqlProcessorQuery query, BiFunction<Config, PreparedSql, RESULT> handler) Creates aSqlProcessorCommandobjectdefault UpdateCommandcreateUpdateCommand(Method method, UpdateQuery query) Creates anUpdateCommandobject.default <RESULT> UpdateReturningCommand<RESULT>createUpdateReturningCommand(Method method, UpdateQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates anUpdateReturningCommandobject.
-
Method Details
-
createSelectCommand
default <RESULT> SelectCommand<RESULT> createSelectCommand(Method method, SelectQuery query, ResultSetHandler<RESULT> resultSetHandler) Creates aSelectCommandobject.- Type Parameters:
RESULT- the result type of the command- Parameters:
method- the DAO methodquery- the queryresultSetHandler- the result set handler- Returns:
- the command
-
createAggregateCommand
default <RESULT,ENTITY> AggregateCommand<RESULT,ENTITY> createAggregateCommand(Method method, SelectQuery query, EntityType<ENTITY> entityType, StreamReducer<RESULT, ENTITY> resultReducer, AggregateStrategyType aggregateStrategyType) Creates anAggregateCommandobject for aggregating entities based on a specified query and strategy.- Type Parameters:
RESULT- the result type of the aggregationENTITY- the entity type used in the aggregation- Parameters:
method- the DAO method associated with the commandquery- the select query to be executedentityType- the type of the root entity for aggregationresultReducer- the reducer used to process the stream of aggregated entities into a final resultaggregateStrategyType- the strategy type used for aggregation logic- Returns:
- a new
AggregateCommandinstance configured with the provided parameters
-
createDeleteCommand
Creates aDeleteCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createInsertCommand
Creates anInsertCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createUpdateCommand
Creates anUpdateCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createDeleteReturningCommand
default <RESULT> DeleteReturningCommand<RESULT> createDeleteReturningCommand(Method method, DeleteQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates aDeleteReturningCommandobject.- Type Parameters:
RESULT- the result type of the command- Parameters:
method- the DAO methodquery- the delete queryresultSetHandler- the handler for processing the result setemptyResultSupplier- the supplier for providing an empty result- Returns:
- the created
DeleteReturningCommandobject
-
createInsertReturningCommand
default <RESULT> InsertReturningCommand<RESULT> createInsertReturningCommand(Method method, InsertQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates anInsertReturningCommandobject.- Parameters:
method- the DAO methodquery- the queryresultSetHandler- the result set handler- Returns:
- the command
-
createUpdateReturningCommand
default <RESULT> UpdateReturningCommand<RESULT> createUpdateReturningCommand(Method method, UpdateQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates anUpdateReturningCommandobject.- Type Parameters:
RESULT- the result type of the command- Parameters:
method- the DAO methodquery- the update queryresultSetHandler- the handler for processing the result setemptyResultSupplier- the supplier for providing an empty result- Returns:
- the created
UpdateReturningCommandobject
-
createBatchDeleteCommand
Creates aBatchDeleteCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createBatchInsertCommand
Creates aBatchInsertCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createBatchUpdateCommand
Creates aBatchUpdateCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createFunctionCommand
default <RESULT> FunctionCommand<RESULT> createFunctionCommand(Method method, FunctionQuery<RESULT> query) Creates aFunctionCommandobject.- Type Parameters:
RESULT- the result type of the command- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createProcedureCommand
Creates aProcedureCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createCreateCommand
default <RESULT> CreateCommand<RESULT> createCreateCommand(Method method, CreateQuery<RESULT> query) Creates aCreateCommandobject.- Type Parameters:
RESULT- the result type of the command- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createScriptCommand
Creates aScriptCommandobject.- Parameters:
method- the DAO methodquery- the query- Returns:
- the command
-
createSqlProcessorCommand
default <RESULT> SqlProcessorCommand<RESULT> createSqlProcessorCommand(Method method, SqlProcessorQuery query, BiFunction<Config, PreparedSql, RESULT> handler) Creates aSqlProcessorCommandobject- Type Parameters:
RESULT- the result type of the command- Parameters:
method- the DAO methodquery- the queryhandler- the SQL handler- Returns:
- the command
-