@Test public void GetOrCreateSession() { assertNull(sessionContext.getCurrentSession()); assertNotNull(sessionContext.getOrCreateSession()); assertNotNull(sessionContext.getCurrentSession()); }
public Session getOrCreateSession() { if (sessionHolder.get() == null) { Session session = sessionFactory.openSession(); sessionHolder.set(session); return session; } else { return sessionHolder.get(); } }
SimpleSessionContext implements SessionContext { public Session getOrCreateSession() { if (sessionHolder.get() == null) { Session session = sessionFactory.openSession(); sessionHolder.set(session); return session; } else { return sessionHolder.get(); } } }
SimpleSessionContext implements SessionContext { public Session getOrCreateSession() { if (sessionHolder.get() == null) { Session session = sessionFactory.openSession(); sessionHolder.set(session); return session; } else { return sessionHolder.get(); } } SimpleSessionContext(SessionFactory sessionFactory); }
SimpleSessionContext implements SessionContext { public Session getOrCreateSession() { if (sessionHolder.get() == null) { Session session = sessionFactory.openSession(); sessionHolder.set(session); return session; } else { return sessionHolder.get(); } } SimpleSessionContext(SessionFactory sessionFactory); @Override Session getCurrentSession(); Session getOrCreateSession(); void releaseSession(); }
SimpleSessionContext implements SessionContext { public Session getOrCreateSession() { if (sessionHolder.get() == null) { Session session = sessionFactory.openSession(); sessionHolder.set(session); return session; } else { return sessionHolder.get(); } } SimpleSessionContext(SessionFactory sessionFactory); @Override Session getCurrentSession(); Session getOrCreateSession(); void releaseSession();  }