Class DeleteReturningCommand<RESULT>
- Type Parameters:
RESULT- the type of result returned from the RETURNING clause
- All Implemented Interfaces:
Command<RESULT>
This command extends ModifyReturningCommand to provide specific functionality for
executing DELETE operations that return data via a RETURNING clause. This is useful for
retrieving values from rows before they are deleted, allowing access to data that would otherwise
be lost after the deletion.
The RETURNING clause is a SQL feature supported by some database systems (like PostgreSQL, Oracle) that allows retrieving data from deleted rows as part of the same statement that performs the deletion, without requiring a separate SELECT statement before the DELETE.
-
Field Summary
Fields inherited from class org.seasar.doma.jdbc.command.ModifyReturningCommand
emptyResultSupplier, query, resultSetHandler, sql -
Constructor Summary
ConstructorsConstructorDescriptionDeleteReturningCommand(DeleteQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates an instance of the DeleteReturningCommand. -
Method Summary
Modifier and TypeMethodDescriptionprotected RESULTexecuteInternal(PreparedStatement preparedStatement) Executes the SQL DELETE statement with a RETURNING clause and processes the returned result set.Methods inherited from class org.seasar.doma.jdbc.command.ModifyReturningCommand
bindParameters, execute, executeQuery, getQuery, handleResultSet, log, prepareStatement, setupOptions
-
Constructor Details
-
DeleteReturningCommand
public DeleteReturningCommand(DeleteQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates an instance of the DeleteReturningCommand.- Parameters:
query- the delete query to execute, containing the SQL statement with a RETURNING clauseresultSetHandler- the handler for processing the result set returned by the RETURNING clauseemptyResultSupplier- the supplier that provides an empty result when no rows are returned or when the RETURNING clause is not supported by the database
-
-
Method Details
-
executeInternal
Executes the SQL DELETE statement with a RETURNING clause and processes the returned result set.This method uses the
StatisticManagerto track execution statistics and delegates to theexecuteQuerymethod to execute the prepared statement. Unlike regular DELETE commands that return the number of affected rows, this method returns data from the RETURNING clause, allowing access to values from the deleted rows.- Specified by:
executeInternalin classModifyReturningCommand<DeleteQuery,RESULT> - Parameters:
preparedStatement- the prepared statement containing the SQL DELETE with RETURNING clause- Returns:
- the result processed from the result set returned by the RETURNING clause
- Throws:
SQLException- if a database access error occurs during execution
-