Skip to content

Instantly share code, notes, and snippets.

@superalsrk
Last active December 15, 2015 21:58
Show Gist options
  • Save superalsrk/5329202 to your computer and use it in GitHub Desktop.
Save superalsrk/5329202 to your computer and use it in GitHub Desktop.
@Before
public void setUp() throws Exception {
ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:/spring/applicationContext.xml");
ordersDAO = (OrdersDAO) ctx.getBean("ordersDAO");
userDAO = (UserDAO) ctx.getBean("userDAO");
houseDAO = (HouseDAO) ctx.getBean("houseDAO");
sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");
session = SessionFactoryUtils.getSession(sessionFactory, true);
session.setFlushMode(FlushMode.MANUAL);
TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
}
@After
public void tearDown() throws Exception {
TransactionSynchronizationManager.unbindResource(sessionFactory);
SessionFactoryUtils.releaseSession(session, sessionFactory);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment