rdeguzman55 wrote:
basterbrugge wrote:
Hi I'm having problem implementing this to Spring-Hibernate integration... perhaps you could give some specific details or tutorial to this?
I resolve the problem by just following this tutorial:
http://www.jroller.com/comments/kbaum/W ... o#comments
and right implementation:
I solve my problem finally.... after searching through the net the answer lies in:
protected void setUp() throws Exception {
super.setUp();
userDao = (UserDAO) ctx.getBean("userDAO");
accountDao = (AccountDAO) ctx.getBean("accountDAO");
sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
}
protected void tearDown() throws Exception {
super.tearDown();
userDao = null;
accountDao = null;
// unbind and close the session.
SessionHolder holder = (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
Session s = holder.getSession();
s.flush();
TransactionSynchronizationManager.unbindResource(sessionFactory);
SessionFactoryUtils.closeSessionIfNecessary(s, sessionFactory);
}