@Inject public void setSessionFactory(SessionFactory sessionFactory) { this.sessionContext = new SimpleSessionContext(sessionFactory); sessionFactory.setSessionContext(sessionContext); }
@Test public void ReleaseSession() { assertNull(sessionContext.getCurrentSession()); assertNotNull(sessionContext.getOrCreateSession()); assertNotNull(sessionContext.getCurrentSession()); sessionContext.releaseSession(); assertNull(sessionContext.getCurrentSession()); }
boolean closeAfterTx = sessionContext.getCurrentSession() == null; Session session = sessionContext.getOrCreateSession(); return new TransactionObject(session, closeAfterTx);
txObj.getSession().setFlushMode(txObj.getOriginalFlushMode()); sessionContext.releaseSession(); txObj.close();
@Test public void GetCurrentSession() { assertNull(sessionContext.getCurrentSession()); }
@Test public void GetOrCreateSession() { assertNull(sessionContext.getCurrentSession()); assertNotNull(sessionContext.getOrCreateSession()); assertNotNull(sessionContext.getCurrentSession()); }
txObj.getSession().setFlushMode(txObj.getOriginalFlushMode()); sessionContext.releaseSession(); if (clearSessionOnRollback) { txObj.getSession().clear();
boolean inSession = false; boolean inTx = false; if (sessionContext.getCurrentSession() != null) { inSession = true; Session session = sessionContext.getCurrentSession(); inTx = session.getTransaction() != null && session.getTransaction().isActive(); Session session = sessionContext.getOrCreateSession(); FlushMode savedFlushMode = session.getFlushMode(); sessionContext.releaseSession(); if (!inSession) { session.close();
/** * Create a new RDFBeanTransactionManager instance. */ public RDFBeanTransactionManager(SessionFactoryImpl sessionFactory) { this.sessionContext = new SimpleSessionContext(sessionFactory); sessionFactory.setSessionContext(sessionContext); setRollbackOnCommitFailure(false); }
boolean inSession = false; boolean inTx = false; if (this.sessionContext.getCurrentSession() != null) { inSession = true; Session session = sessionContext.getCurrentSession(); inTx = session.getTransaction() != null && session.getTransaction().isActive(); Session session = sessionContext.getOrCreateSession(); FlushMode savedFlushMode = session.getFlushMode(); sessionContext.releaseSession(); if (!inSession) { session.close();
public TransactionalAdvisorImpl(SessionFactory sessionFactory) { this.sessionContext = new SimpleSessionContext(sessionFactory); this.advice = new TransactionalMethodAdvice(this, sessionContext); sessionFactory.setSessionContext(sessionContext); }
@Before public void setUp() { sessionFactory = new SessionFactoryImpl(); sessionFactory.setConfiguration(new DefaultConfiguration()); sessionFactory.setRepository(new MiniRepository()); sessionFactory.initialize(); sessionContext = new SimpleSessionContext(sessionFactory); }