spring-framework / org.springframework.orm.hibernate5.support / OpenSessionInterceptor

OpenSessionInterceptor

open class OpenSessionInterceptor : MethodInterceptor, InitializingBean

Simple AOP Alliance MethodInterceptor implementation that binds a new Hibernate Session 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 new Session with flush mode "MANUAL" since the Session is only meant for reading, except when participating in a transaction.

Author
Juergen Hoeller

Since
4.2

See Also
OpenSessionInViewInterceptorOpenSessionInViewFilterorg.springframework.orm.hibernate5.HibernateTransactionManagerTransactionSynchronizationManagerSessionFactory#getCurrentSession()

Constructors

<init>

OpenSessionInterceptor()

Simple AOP Alliance MethodInterceptor implementation that binds a new Hibernate Session 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 new Session with flush mode "MANUAL" since the Session is only meant for reading, except when participating in a transaction.

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

getSessionFactory

open fun getSessionFactory(): SessionFactory

Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.

invoke

open fun invoke(invocation: MethodInvocation): Any

setSessionFactory

open fun setSessionFactory(sessionFactory: SessionFactory): Unit

Set the Hibernate SessionFactory that should be used to create Hibernate Sessions.