Class UpdateCommand

java.lang.Object
org.seasar.doma.jdbc.command.ModifyCommand<UpdateQuery>
org.seasar.doma.jdbc.command.UpdateCommand
All Implemented Interfaces:
Command<Integer>

public class UpdateCommand extends ModifyCommand<UpdateQuery>
A command that executes UPDATE SQL statements.

This class extends ModifyCommand to provide specific functionality for executing UPDATE operations in a database. It handles the execution of prepared statements for updating data and tracks execution statistics.

The command returns the number of rows affected by the UPDATE operation. It also increments the version number for entities that use optimistic locking.

  • Constructor Details

    • UpdateCommand

      public UpdateCommand(UpdateQuery query)
      Constructs a new UpdateCommand with the specified query.
      Parameters:
      query - the update query to execute, which contains the SQL statement and configuration
  • Method Details

    • executeInternal

      protected int executeInternal(PreparedStatement preparedStatement) throws SQLException
      Executes the UPDATE statement and returns the number of affected rows.

      This method uses the statistic manager to track execution statistics for the SQL operation if statistics collection is enabled. It also increments the version number for entities that use optimistic locking after the update operation is completed.

      Specified by:
      executeInternal in class ModifyCommand<UpdateQuery>
      Parameters:
      preparedStatement - the prepared statement to execute
      Returns:
      the number of rows affected by the UPDATE operation
      Throws:
      SQLException - if a database access error occurs during execution