Package org.hibernate.jdbc
Class Expectation.OutParameter
java.lang.Object
org.hibernate.jdbc.Expectation.OutParameter
- All Implemented Interfaces:
Expectation
- Enclosing interface:
- Expectation
Essentially identical to
Expectation.RowCount
except that the row count
is obtained via an output parameter of a stored procedure
.
Statement batching is disabled when OutParameter
is used.
- 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 -
Method Summary
Modifier and TypeMethodDescriptionboolean
Is it acceptable to combine this expectation with JDBC statement batching? If this method returnsfalse
, the use of batch updates is disabled.protected int
int
The number of JDBC parameters this expectation uses.protected int
int
prepare
(PreparedStatement statement) Perform any special statement preparation, for example, registration of OUT parameters.void
validate
(boolean callable) Check that this implementation is compatible with the kind ofPreparedStatement
it will be called with.final 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
.
-
Constructor Details
-
OutParameter
public OutParameter()
-
-
Method Details
-
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:
- The argument to
-
validate
Description copied from interface:Expectation
Check that this implementation is compatible with the kind ofPreparedStatement
it will be called with. Implementors should throw aMappingException
if the configuration is not supported. This operation is called when Hibernate starts up, so that incompatibilities are detected and reported as early as possible.- Specified by:
validate
in interfaceExpectation
- Parameters:
callable
- true if thisExpectation
will be called with aCallableStatement
.- Throws:
MappingException
-
getNumberOfParametersUsed
public int getNumberOfParametersUsed()Description copied from interface:Expectation
The number of JDBC parameters this expectation uses. For example,Expectation.OutParameter
requires a single OUT parameter for reading back the number of affected rows.- Specified by:
getNumberOfParametersUsed
in interfaceExpectation
-
prepare
Description copied from interface:Expectation
Perform any special statement preparation, for example, registration of OUT parameters.- Specified by:
prepare
in interfaceExpectation
- Parameters:
statement
- The statement to be prepared- Returns:
- The number of bind positions consumed (if any)
- Throws:
SQLException
- Exception from the JDBC driverHibernateException
- Problem performing preparation.- See Also:
-
canBeBatched
public boolean canBeBatched()Description copied from interface:Expectation
Is it acceptable to combine this expectation with JDBC statement batching? If this method returnsfalse
, the use of batch updates is disabled.- Specified by:
canBeBatched
in interfaceExpectation
- Returns:
- True if batching can be combined with this expectation; false otherwise.
- See Also:
-
parameterIndex
protected int parameterIndex() -
expectedRowCount
protected int expectedRowCount()
-