Class UpdateReturningCommand<RESULT>

java.lang.Object
org.seasar.doma.jdbc.command.ModifyReturningCommand<UpdateQuery,RESULT>
org.seasar.doma.jdbc.command.UpdateReturningCommand<RESULT>
Type Parameters:
RESULT - the type of result returned from the RETURNING clause
All Implemented Interfaces:
Command<RESULT>

public class UpdateReturningCommand<RESULT> extends ModifyReturningCommand<UpdateQuery,RESULT>
A command that executes an SQL UPDATE statement and retrieves a result set generated from a RETURNING clause.

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.

  • 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 clause
      resultSetHandler - the handler for processing the result set returned by the RETURNING clause
      emptyResultSupplier - 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

      protected RESULT executeInternal(PreparedStatement preparedStatement) throws SQLException
      Executes the SQL UPDATE statement with a RETURNING clause and processes the returned result set.

      This method uses the StatisticManager to track execution statistics and delegates to the executeQuery method 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:
      executeInternal in class ModifyReturningCommand<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