Code example for SessionFactory

Methods: close

0
            assertEquals(pojo.getFoo(), pojo2.getFoo());
        } finally { 
            if (session != null && session.isOpen()) {
                session.close();
            } 
            factory.close();
        } 
    } 
 
    @Test
    public void canInvokeStringAndHashcodeOnScopedSession() { 
        SessionFactory factory = (new ConstructableConfiguration("/hibernate.cfg.xml")).buildSessionFactory();
        ScopedSession session = new ScopedSession(factory);
        int beforeCreationHashCode = session.hashCode();
        assertTrue(beforeCreationHashCode > 0);
        assertNotNull(session.toString());
 
        // Force lazy creation of a session. 
        Session delegate = session.getDelegate();
        assertNotNull(delegate);