Class OpenSessionInterceptor
- java.lang.Object
- org.springframework.orm.hibernate3.support.OpenSessionInterceptor
- All Implemented Interfaces:
Advice
,Interceptor
,MethodInterceptor
,InitializingBean
@Deprecated public class OpenSessionInterceptor extends Object implements MethodInterceptor, InitializingBean
Deprecated.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.- Since:
- 4.0.2
- Author:
- Juergen Hoeller
- See Also:
OpenSessionInViewInterceptor
,OpenSessionInViewFilter
,HibernateTransactionManager
,TransactionSynchronizationManager
,SessionFactory.getCurrentSession()
Constructor Summary
Constructors Constructor Description OpenSessionInterceptor()
Deprecated.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
afterPropertiesSet()
Deprecated.Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.SessionFactory
getSessionFactory()
Deprecated.Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.Object
invoke(MethodInvocation invocation)
Deprecated.Implement this method to perform extra treatments before and after the invocation.protected Session
openSession()
Deprecated.Open a Session for the SessionFactory that this interceptor uses.void
setSessionFactory(SessionFactory sessionFactory)
Deprecated.Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.
Constructor Detail
OpenSessionInterceptor
public OpenSessionInterceptor()
Deprecated.
Method Detail
setSessionFactory
public void setSessionFactory(SessionFactory sessionFactory)
Deprecated.Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.
getSessionFactory
public SessionFactory getSessionFactory()
Deprecated.Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.
afterPropertiesSet
public void afterPropertiesSet()
Deprecated.Description copied from interface: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.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
invoke
public Object invoke(MethodInvocation invocation) throws Throwable
Deprecated.Description copied from interface:MethodInterceptor
Implement this method to perform extra treatments before and after the invocation. Polite implementations would certainly like to invokeJoinpoint.proceed()
.- Specified by:
invoke
in interfaceMethodInterceptor
- Parameters:
invocation
- the method invocation joinpoint- Returns:
- the result of the call to
Joinpoint.proceed()
; might be intercepted by the interceptor - Throws:
Throwable
- if the interceptors or the target object throws an exception
openSession
protected Session openSession() throws DataAccessResourceFailureException
Deprecated.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".- Returns:
- the Session to use
- Throws:
DataAccessResourceFailureException
- if the Session could not be created- See Also:
FlushMode.MANUAL