Package org.hibernate.jdbc
package org.hibernate.jdbc
A small API allowing the client of a Hibernate session to interact directly
with JDBC, using the same connection and transaction obtained by the session.
Work and ReturningWork
define the notion of a unit of JDBC work that may be executed by the session
at the request of the client. Execution of a unit of work may be requested by
calling:
-
SharedSessionContract.doWork(org.hibernate.jdbc.Work)or -
SharedSessionContract.doReturningWork(org.hibernate.jdbc.ReturningWork).
For example:
session.doWork(connection -> {
try ( PreparedStatement ps = connection.prepareStatement( " ... " ) ) {
ps.execute();
}
});
The interface Expectation defines a contract for
checking the results of a JDBC operation which executes user-written SQL:
Expectation.RowCountis used to check returned row counts,Expectation.OutParameteris used to check out parameters of stored procedures, and- user-written implementations of
Expectationare also supported.
Expectation class may be specified along with the user-written SQL
using SQLInsert.verify(),
SQLUpdate.verify(), or
SQLDelete.verify().- See Also:
-
ClassDescriptionAn abstract implementation of
ReturningWorkthat accepts aWorkExecutorvisitor for executing a discrete piece of work and returning a result.An abstract implementation ofWorkthat accepts aWorkExecutorvisitor for executing a discrete piece of work.Much likeTooManyRowsAffectedException, indicates that more rows than what we were expecting were affected.Indicates a failed batch entry (-3 return).Defines an expected DML operation outcome.No return code checking.Essentially identical toExpectation.RowCountexcept that the row count is obtained via an output parameter of astored procedure.Row count checking.Useful operations for dealing withExpectations.Deprecated.Deprecated.UseExpectation.OutParameter, creating a custom subclass if necessaryA discrete piece of work making use of a JDBC connection and returning a result.Indicates that more rows were affected then we were expecting to be.A discrete piece of work making use of a JDBC connection.WorkExecutor<T>A visitor used for executing a discrete piece of work encapsulated in aWorkorReturningWorkinstance.This interface provides a way to execute unrelated "work" objects using polymorphism.
Expectation.RowCount, creating a custom subclass if necessary