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 andReturningWork 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)orSharedSessionContract.doReturningWork(org.hibernate.jdbc.ReturningWork).
For example:
session.doWork(connection -> { try ( PreparedStatement ps = connection.prepareStatement( " ... " ) ) { ps.execute(); } }); The interfaceExpectation 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 usingSQLInsert.verify(),SQLUpdate.verify(), orSQLDelete.verify().- See Also:
Work,ReturningWork,Expectation
Interface Summary Interface Description Expectation Defines an expected DML operation outcome.ReturningWork<T> A discrete piece of work making use of aJDBC connection and returning a result.Work A discrete piece of work making use of aJDBC connection.WorkExecutorVisitable<T> This interface provides a way to execute unrelated "work" objects using polymorphism.Class Summary Class Description AbstractReturningWork<T> An abstract implementation ofReturningWorkthat accepts aWorkExecutorvisitor for executing a discrete piece of work and returning a result.AbstractWork An abstract implementation ofWorkthat accepts aWorkExecutorvisitor for executing a discrete piece of work.Expectation.None No return code checking.Expectation.OutParameter Essentially identical toExpectation.RowCountexcept that the row count is obtained via an output parameter of astored procedure.Expectation.RowCount Row count checking.Expectations Useful operations for dealing withExpectations.Expectations.BasicExpectation Deprecated. UseExpectation.RowCount, creating a custom subclass if necessaryExpectations.BasicParamExpectation Deprecated. UseExpectation.OutParameter, creating a custom subclass if necessaryWorkExecutor<T> A visitor used for executing a discrete piece of work encapsulated in aWorkorReturningWorkinstance.Exception Summary Exception Description BatchedTooManyRowsAffectedException Much likeTooManyRowsAffectedException, indicates that more rows than what we were expecting were affected.BatchFailedException Indicates a failed batch entry (-3 return).TooManyRowsAffectedException Indicates that more rows were affected then we were expecting to be.