Class UpdateReturningCommand<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 UPDATE operations that return data via a RETURNING clause. This is useful for
retrieving auto-generated values or other column values after an update operation.
The RETURNING clause is a SQL feature supported by some database systems (like PostgreSQL, Oracle) that allows retrieving data from modified rows as part of the same statement that performs the modification, without requiring a separate SELECT statement.
-
Field Summary
Fields inherited from class org.seasar.doma.jdbc.command.ModifyReturningCommand
emptyResultSupplier, query, resultSetHandler, sql -
Constructor Summary
ConstructorsConstructorDescriptionUpdateReturningCommand(UpdateQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates an instance of the UpdateReturningCommand. -
Method Summary
Modifier and TypeMethodDescriptionprotected RESULTexecuteInternal(PreparedStatement preparedStatement) Executes the SQL UPDATE 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
-
UpdateReturningCommand
public UpdateReturningCommand(UpdateQuery query, ResultSetHandler<RESULT> resultSetHandler, Supplier<RESULT> emptyResultSupplier) Creates an instance of the UpdateReturningCommand.- Parameters:
query- the update 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 UPDATE 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 UPDATE commands that return the number of affected rows, this method returns data from the RETURNING clause.- Specified by:
executeInternalin classModifyReturningCommand<UpdateQuery,RESULT> - Parameters:
preparedStatement- the prepared statement containing the SQL UPDATE 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
-