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.RowCount
is used to check returned row counts,Expectation.OutParameter
is used to check out parameters of stored procedures, and- user-written implementations of
Expectation
are 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
ReturningWork
that accepts aWorkExecutor
visitor for executing a discrete piece of work and returning a result.An abstract implementation ofWork
that accepts aWorkExecutor
visitor 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.RowCount
except that the row count is obtained via an output parameter of astored procedure
.Row count checking.Useful operations for dealing withExpectation
s.A discrete piece of work making use of a JDBC connection and returning a result.Indicates that more rows were affected than 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 aWork
orReturningWork
instance.This interface provides a way to execute unrelated "work" objects using polymorphism.