类 OpenSessionInterceptor
- java.lang.Object
- org.springframework.orm.hibernate3.support.OpenSessionInterceptor
- 所有已实现的接口:
Advice
,Interceptor
,MethodInterceptor
,InitializingBean
@Deprecated public class OpenSessionInterceptor extends Object implements MethodInterceptor, InitializingBean
已过时。as of Spring 4.3, in favor of Hibernate 4.x/5.xSimple AOP AllianceMethodInterceptor
implementation that binds a new HibernateSession
for each method invocation, if none bound before.This is a simple Hibernate Session scoping interceptor along the lines of
OpenSessionInViewInterceptor
, just for use with AOP setup instead of MVC setup. It opens a newSession
with flush mode "MANUAL" since the Session is only meant for reading, except when participating in a transaction.Note: This can serve as a streamlined alternative to the outdated
HibernateInterceptor
, providing plain Session binding without any automatic exception translation or the like.- 从以下版本开始:
- 4.0.2
- 作者:
- Juergen Hoeller
- 另请参阅:
OpenSessionInViewInterceptor
,OpenSessionInViewFilter
,HibernateTransactionManager
,TransactionSynchronizationManager
,SessionFactory.getCurrentSession()
构造器概要
构造器 构造器 说明 OpenSessionInterceptor()
已过时。
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
已过时。Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.SessionFactory
getSessionFactory()
已过时。Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.Object
invoke(MethodInvocation invocation)
已过时。Implement this method to perform extra treatments before and after the invocation.protected Session
openSession()
已过时。Open a Session for the SessionFactory that this interceptor uses.void
setSessionFactory(SessionFactory sessionFactory)
已过时。Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.
构造器详细资料
OpenSessionInterceptor
public OpenSessionInterceptor()
已过时。
方法详细资料
setSessionFactory
public void setSessionFactory(SessionFactory sessionFactory)
已过时。Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.
getSessionFactory
public SessionFactory getSessionFactory()
已过时。Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.
afterPropertiesSet
public void afterPropertiesSet()
已过时。从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
invoke
public Object invoke(MethodInvocation invocation) throws Throwable
已过时。从接口复制的说明:MethodInterceptor
Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invokeJoinpoint.proceed()
.- 指定者:
invoke
在接口中MethodInterceptor
- 参数:
invocation
- the method invocation joinpoint- 返回:
- the result of the call to
Joinpoint.proceed()
; might be intercepted by the interceptor - 抛出:
Throwable
- if the interceptors or the target object throws an exception
openSession
protected Session openSession() throws DataAccessResourceFailureException
已过时。Open a Session for the SessionFactory that this interceptor uses.The default implementation delegates to the
SessionFactory.openSession()
method and sets theSession
's flush mode to "MANUAL".- 返回:
- the Session to use
- 抛出:
DataAccessResourceFailureException
- if the Session could not be created- 另请参阅:
FlushMode.MANUAL