开发者

Obtaining session in Hibernate Listener with Spring Integration

开发者 https://www.devze.com 2023-01-16 16:32 出处:网络
When Hibernate is used with Spring, making the DAOs extend HibernateDaoSupport provides the getHibernateTemplate() which is used to obtain the session.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消