statelessSession = sessionFactory.openStatelessSession();
@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")); }
StatelessSession getStatelessSession() { if (sf != null) { return sf.openStatelessSession(); } throw new PersistenceException("Session factory is not initialized"); } }
try { SessionFactory sessionFactory = entityManagerFactory().unwrap( SessionFactory.class ); statelessSession = sessionFactory.openStatelessSession();
@Test @TestForIssue( jiraKey = "HHH-11732" ) public void test() { Triggerable triggerable = logInspection.watchForLogMessages( "HHH000352" ); triggerable.reset(); StatelessSession session = entityManagerFactory().unwrap( SessionFactory.class ).openStatelessSession(); Transaction tx = session.beginTransaction(); try { Employee employee = new Employee( "1", "2", 1 ); employee.setId( 1 ); session.insert( employee ); tx.rollback(); } catch (HibernateException e) { if ( tx != null ) { tx.rollback(); } } finally { session.close(); assertFalse( triggerable.wasTriggered() ); } }
StatelessSession session = sf.openStatelessSession(); if (!pu.equals(getPersistenceUnit()))
@Override public StatelessSession openStatelessSession() { return delegate.openStatelessSession(); }
@Override public StatelessSession openStatelessSession() { return delegate.openStatelessSession(); }
/** {@inheritDoc} **/ public StatelessSession openStatelessSession(Connection connection) { return delegate.openStatelessSession(connection); }
/** {@inheritDoc} **/ public StatelessSession openStatelessSession(Connection connection) { return delegate.openStatelessSession(connection); }
/** {@inheritDoc} **/ public StatelessSession openStatelessSession() { return delegate.openStatelessSession(); }
/** {@inheritDoc} **/ public StatelessSession openStatelessSession() { return delegate.openStatelessSession(); }
protected StatelessSession openSession() { if (currentSessionHolder.get() != null) { throw new IllegalStateException("session already open"); } StatelessSession session = sessionFactory.openStatelessSession(); currentSessionHolder.set(session); log.debug("open new session [{}]", currentSessionHolder.get()); return session; } }
StatelessSession getStatelessSession() { if (sf != null) { return sf.openStatelessSession(); } throw new PersistenceException("Session factory is not initialized"); } }
/** * Open a new stateless session. * * @return the created stateless session */ private static StatelessSession openStatelessSession() { assertSessionFactory(); return sessionFactory.openStatelessSession(); }
public StatelessSession openStatelessSession() { return getSessionFactory().openStatelessSession(); }
StatelessSession getStatelessSession() { if (sf != null) { return sf.openStatelessSession(); } throw new PersistenceException("Session factory is not initialized"); } }
@Override public void saveOrUpdateStateless(ChannelVulnerability channelVulnerability) { StatelessSession statelessSession = sessionFactory.openStatelessSession(); statelessSession.insert(channelVulnerability); statelessSession.close(); }
@Override public void insert(List<ChannelSeverity> channelSeverities) { StatelessSession statelessSession = sessionFactory.openStatelessSession(); try { for (ChannelSeverity channelSeverity : channelSeverities) { statelessSession.insert(channelSeverity); } } finally { statelessSession.close(); } }