Code example for SessionFactory

Methods: openSession

0
 
    public static void setUpSession(SessionFactory sessionFactory, boolean clearActiveTX) {
        if (clearActiveTX) {
            if (TransactionSynchronizationManager.isSynchronizationActive()) { 
                try { 
                    TransactionSynchronizationManager.unbindResource(sessionFactory);
                } 
                catch(IllegalStateException e) {}
                TransactionSynchronizationManager.clearSynchronization(); 
            } 
        } 
         
        setUpSession(sessionFactory);
    } 
    public static void setUpSession(SessionFactory sessionFactory) {
        Session session = sessionFactory.openSession();
         
        TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
        TransactionSynchronizationManager.initSynchronization(); 
    } 
     
    public static void tearDownSession(SessionFactory sessionFactory, Throwable error) {
        Session session = sessionFactory.getCurrentSession();
Connect your IDE to all the code out there  Get Codota for Java