even more javadoc for Expectation
This commit is contained in:
parent
d7ef693768
commit
e3076966c7
|
@ -49,46 +49,78 @@ import static org.hibernate.jdbc.Expectations.toCallableStatement;
|
||||||
public interface Expectation {
|
public interface Expectation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is it acceptable to combine this expectation with statement batching?
|
* Is it acceptable to combine this expectation with JDBC
|
||||||
|
* {@linkplain PreparedStatement#executeBatch() statement batching}?
|
||||||
|
* If this method returns {@code false}, the use of batch updates
|
||||||
|
* is disabled.
|
||||||
*
|
*
|
||||||
* @return True if batching can be combined with this expectation; false otherwise.
|
* @return True if batching can be combined with this expectation;
|
||||||
|
* false otherwise.
|
||||||
|
*
|
||||||
|
* @see PreparedStatement#executeBatch()
|
||||||
*/
|
*/
|
||||||
default boolean canBeBatched() {
|
default boolean canBeBatched() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of parameters this expectation implies. E.g.,
|
* The number of JDBC parameters this expectation uses. For example,
|
||||||
* {@link OutParameter} requires a single OUT parameter for
|
* {@link OutParameter} requires a single OUT parameter for reading
|
||||||
* reading back the number of affected rows.
|
* back the number of affected rows.
|
||||||
*/
|
*/
|
||||||
default int getNumberOfParametersUsed() {
|
default int getNumberOfParametersUsed() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform verification of the outcome of the RDBMS operation based on
|
* Perform verification of the outcome of the JDBC operation based
|
||||||
* the type of expectation defined.
|
* on the type of expectation defined, after execution of the given
|
||||||
|
* {@link PreparedStatement}. When a SQL statement is executed via
|
||||||
|
* {@link PreparedStatement#executeUpdate()}, {@code verifyOutcome()}
|
||||||
|
* is called exactly once. When {@link PreparedStatement#executeBatch()}
|
||||||
|
* is used to execute a batch update, this method is called once for
|
||||||
|
* each element of the batch.
|
||||||
|
* <ul>
|
||||||
|
* <li>The argument to {@code rowCount} is usually the number of
|
||||||
|
* table rows affected by execution of the SQL statement via
|
||||||
|
* {@code executeUpdate()}. However, in the case where
|
||||||
|
* {@code executeBatch()} is used to execute a batch update,
|
||||||
|
* it might be {@link PreparedStatement#EXECUTE_FAILED} or
|
||||||
|
* {@link PreparedStatement#SUCCESS_NO_INFO}.
|
||||||
|
* <li>The argument to {@code batchPosition} is negative unless
|
||||||
|
* {@code executeBatch()} is used to execute a batch update,
|
||||||
|
* in which case it is the position within the batch of the
|
||||||
|
* row count being verified.
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param rowCount The RDBMS reported "number of rows affected".
|
* @param rowCount The RDBMS reported "number of rows affected"
|
||||||
* @param statement The statement representing the operation
|
* @param statement The statement representing the operation
|
||||||
* @param batchPosition The position in the batch (if batching)
|
* @param batchPosition The position in the batch (if batching),
|
||||||
* @param sql The SQL backing the prepared statement, for logging purposes
|
* or {@code -1} if not part of a batch
|
||||||
* @throws SQLException Exception from the JDBC driver
|
* @param sql The SQL backing the prepared statement, for error
|
||||||
|
* reporting and logging purposes
|
||||||
|
* @throws SQLException Exception from the JDBC driver.
|
||||||
* @throws HibernateException Problem processing the outcome.
|
* @throws HibernateException Problem processing the outcome.
|
||||||
|
*
|
||||||
|
* @see PreparedStatement#executeUpdate()
|
||||||
|
* @see PreparedStatement#executeBatch()
|
||||||
*/
|
*/
|
||||||
void verifyOutcome(int rowCount, PreparedStatement statement, int batchPosition, String sql)
|
void verifyOutcome(int rowCount, PreparedStatement statement, int batchPosition, String sql)
|
||||||
throws SQLException, HibernateException;
|
throws SQLException, HibernateException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform any special statement preparation.
|
* Perform any special statement preparation, for example,
|
||||||
|
* registration of OUT parameters.
|
||||||
*
|
*
|
||||||
* @param statement The statement to be prepared
|
* @param statement The statement to be prepared
|
||||||
* @return The number of bind positions consumed (if any)
|
* @return The number of bind positions consumed (if any)
|
||||||
* @throws SQLException Exception from the JDBC driver
|
* @throws SQLException Exception from the JDBC driver
|
||||||
* @throws HibernateException Problem performing preparation.
|
* @throws HibernateException Problem performing preparation.
|
||||||
|
*
|
||||||
|
* @see CallableStatement#registerOutParameter(int, int)
|
||||||
*/
|
*/
|
||||||
default int prepare(PreparedStatement statement) throws SQLException, HibernateException {
|
default int prepare(PreparedStatement statement)
|
||||||
|
throws SQLException, HibernateException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +128,9 @@ public interface Expectation {
|
||||||
* Check that this implementation is compatible with the kind of
|
* Check that this implementation is compatible with the kind of
|
||||||
* {@link PreparedStatement} it will be called with. Implementors
|
* {@link PreparedStatement} it will be called with. Implementors
|
||||||
* should throw a {@link MappingException} if the configuration
|
* should throw a {@link MappingException} if the configuration
|
||||||
* is not supported.
|
* is not supported. This operation is called when Hibernate
|
||||||
|
* starts up, so that incompatibilities are detected and reported
|
||||||
|
* as early as possible.
|
||||||
*
|
*
|
||||||
* @param callable true if this {@code Expectation} will be called
|
* @param callable true if this {@code Expectation} will be called
|
||||||
* with a {@link CallableStatement}.
|
* with a {@link CallableStatement}.
|
||||||
|
|
Loading…
Reference in New Issue