Code example for SessionFactory

Methods: isClosed

0
     *            new configuration for the session factory 
     */ 
    static void rebuildSessionFactory( 
            final org.hibernate.cfg.Configuration config) {
        log.debug("Rebuilding the Hibernate Session Factory from new Config"); 
        if (sessionFactory != null && !sessionFactory.isClosed()) {
            /* if still open, close current session factory */ 
            sessionFactory.close();
        } 
        /* build a new session factory and update static config */ 
        try { 
            sessionFactory = config.buildSessionFactory();
        } catch (Exception e) {
            if (e instanceof java.sql.SQLException) {
                log.error("Building Hibernate Session failed due to" 
                        + " an SQLExeption: " + e.getMessage());
            } else { 
                log.error("Building Hibernate Session failed due to" 
                        + " some unexpected Behaviour: " + e.getMessage());
            }