Interface HibernateCallback<T>
- Type Parameters:
T- the result type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback interface for Hibernate code. To be used with
HibernateTemplate's
execution methods, often as anonymous classes within a method implementation.
A typical implementation will call Session.load/find/update to perform
some operations on persistent objects.- Since:
- 4.2
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondoInHibernate(Session session) Gets called byHibernateTemplate.executewith an active HibernateSession.
-
Method Details
-
doInHibernate
Gets called byHibernateTemplate.executewith an active HibernateSession. Does not need to care about activating or closing theSession, or handling transactions.Allows for returning a result object created within the callback, i.e. a domain object or a collection of domain objects. A thrown custom RuntimeException is treated as an application exception: It gets propagated to the caller of the template.
- Parameters:
session- active Hibernate session- Returns:
- a result object, or
nullif none - Throws:
HibernateException- if thrown by the Hibernate API- See Also:
-