lock hibernate session to avoid lazy loading exceptions in tests

Tuesday, March 04, 2008

//Lock this hibernate session so we don't get lazy loading exceptions
SessionFactory sessionFactory = (SessionFactory) appContext.getBean("sessionFactory");
Session session = SessionFactoryUtils.getSession(sessionFactory, true);
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));

0 comments:

Post a Comment