/** * The Hibernate SessionFactory to use the create a session. * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { helper.setSessionFactory(sessionFactory); }
/** * The Hibernate SessionFactory to use the create a session. * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { helper.setSessionFactory(sessionFactory); }
@Test public void testOneSessionForAllPages() throws Exception { StatelessSession session = mock(StatelessSession.class); when(sessionFactory.openStatelessSession()).thenReturn(session); helper.setSessionFactory(sessionFactory); helper.createQuery(); // Multiple calls to createQuery only creates one session helper.createQuery(); }
@Test public void testSessionReset() throws Exception { StatelessSession session = mock(StatelessSession.class); when(sessionFactory.openStatelessSession()).thenReturn(session); helper.setSessionFactory(sessionFactory); helper.createQuery(); assertNotNull(ReflectionTestUtils.getField(helper, "statelessSession")); helper.close(); assertNull(ReflectionTestUtils.getField(helper, "statelessSession")); }
/** * The Hibernate SessionFactory to use the create a session. * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { helper.setSessionFactory(sessionFactory); }
/** * The Hibernate SessionFactory to use the create a session. * * @param sessionFactory the {@link SessionFactory} to set */ public void setSessionFactory(SessionFactory sessionFactory) { helper.setSessionFactory(sessionFactory); }