Obtaining session in Hibernate Listener with Spring Integration
When Hibernate is used with Spring, making the DAOs extend HibernateDaoSupport provides the getHibernateTemplate() which is used to obtain the session.
When using a Hibernate Event Listener, I am extending the SaveOrUpdateEventListener and so cannot use the getHi开发者_StackOverflow社区bernateTemplate() method to obtain Session.
Is there any way to obtain the session via Spring ?
Have you tried to call event.getSession()
in the listener?. Since listener is executed in the context of session, you doesn't need to obtain session via Spring.
精彩评论