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:
Work
,ReturningWork
,Expectation
-
Interface Summary Interface Description Expectation Defines an expected DML operation outcome.ReturningWork<T> A discrete piece of work making use of a JDBC connection and returning a result.Work A discrete piece of work making use of a JDBC connection.WorkExecutorVisitable<T> This interface provides a way to execute unrelated "work" objects using polymorphism. -
Class Summary Class Description AbstractReturningWork<T> An abstract implementation ofReturningWork
that accepts aWorkExecutor
visitor for executing a discrete piece of work and returning a result.AbstractWork An abstract implementation ofWork
that accepts aWorkExecutor
visitor for executing a discrete piece of work.Expectation.None No return code checking.Expectation.OutParameter Essentially identical toExpectation.RowCount
except that the row count is obtained via an output parameter of astored procedure
.Expectation.RowCount Row count checking.Expectations Useful operations for dealing withExpectation
s.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 aWork
orReturningWork
instance. -
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.