接口 HibernateCallback<T>
public interface HibernateCallback<T>
Callback interface for Hibernate code. To be used withHibernateTemplate
's execution methods, often as anonymous classes within a method implementation. A typical implementation will callSession.load/find/update
to perform some operations on persistent objects.- 从以下版本开始:
- 4.0.1
- 作者:
- Juergen Hoeller
- 另请参阅:
HibernateTemplate
,HibernateTransactionManager
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 T
doInHibernate(Session session)
Gets called byHibernateTemplate.execute
with an active HibernateSession
.
方法详细资料
doInHibernate
T doInHibernate(Session session) throws HibernateException
Gets called byHibernateTemplate.execute
with 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.
- 参数:
session
- active Hibernate session- 返回:
- a result object, or
null
if none - 抛出:
HibernateException
- if thrown by the Hibernate API- 另请参阅:
HibernateTemplate.execute(org.springframework.orm.hibernate4.HibernateCallback<T>)