Package org.hibernate.jdbc
Class Expectation.RowCount
- java.lang.Object
-
- org.hibernate.jdbc.Expectation.RowCount
-
- All Implemented Interfaces:
Expectation
- Direct Known Subclasses:
Expectations.BasicExpectation
- Enclosing interface:
- Expectation
public static class Expectation.RowCount extends Object implements Expectation
Row count checking. A row count is an integer value returned byPreparedStatement.executeUpdate()
orStatement.executeBatch()
. The row count is checked against an expected value. For example, the expected row count for anINSERT
statement is always 1.- Since:
- 6.5
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.jdbc.Expectation
Expectation.None, Expectation.OutParameter, Expectation.RowCount
-
-
Constructor Summary
Constructors Constructor Description RowCount()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
expectedRowCount()
void
verifyOutcome(int rowCount, PreparedStatement statement, int batchPosition, String sql)
Perform verification of the outcome of the JDBC operation based on the type of expectation defined, after execution of the givenPreparedStatement
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.jdbc.Expectation
canBeBatched, getNumberOfParametersUsed, prepare, validate
-
-
-
-
Method Detail
-
verifyOutcome
public final void verifyOutcome(int rowCount, PreparedStatement statement, int batchPosition, String sql)
Description copied from interface:Expectation
Perform verification of the outcome of the JDBC operation based on the type of expectation defined, after execution of the givenPreparedStatement
. When a SQL statement is executed viaPreparedStatement.executeUpdate()
,verifyOutcome()
is called exactly once. WhenStatement.executeBatch()
is used to execute a batch update, this method is called once for each element of the batch.- The argument to
rowCount
is usually the number of table rows affected by execution of the SQL statement viaexecuteUpdate()
. However, in the case whereexecuteBatch()
is used to execute a batch update, it might beStatement.EXECUTE_FAILED
orStatement.SUCCESS_NO_INFO
. - The argument to
batchPosition
is negative unlessexecuteBatch()
is used to execute a batch update, in which case it is the position within the batch of the row count being verified.
- Specified by:
verifyOutcome
in interfaceExpectation
- Parameters:
rowCount
- The RDBMS reported "number of rows affected"statement
- The statement representing the operationbatchPosition
- The position in the batch (if batching), or-1
if not part of a batchsql
- The SQL backing the prepared statement, for error reporting and logging purposes- See Also:
PreparedStatement.executeUpdate()
,Statement.executeBatch()
- The argument to
-
expectedRowCount
protected int expectedRowCount()
-
-