public Connection close() throws HibernateException { log.trace( "closing session" ); if ( factory.getStatistics().isStatisticsEnabled() ) factory.getStatisticsImplementor().closeSession(); try { try { if ( childSessionsByEntityMode != null ) { Iterator childSessions = childSessionsByEntityMode.values().iterator(); while ( childSessions.hasNext() ) { final SessionImpl child = ( SessionImpl ) childSessions.next(); child.close(); } } } catch( Throwable t ) { // just ignore } if ( isRootSession ) { return jdbcContext.getConnectionManager().close(); } else { return null; } } finally { closed = true; cleanup(); } }
private SessionImpl(SessionImpl parent, EntityMode entityMode) { this.factory = parent.factory; this.timestamp = parent.timestamp; this.jdbcContext = parent.jdbcContext; this.interceptor = parent.interceptor; this.listeners = parent.listeners; this.actionQueue = new ActionQueue(this); this.entityMode = entityMode; this.persistenceContext = new PersistenceContext(this); this.flushBeforeCompletionEnabled = false; this.autoCloseSessionEnabled = false; this.connectionReleaseMode = null; this.isRootSession = false; if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession(); } log.debug( "opened session [" + entityMode + "]" ); }
/** * Constructor used in building "child sessions". * * @param parent The parent session * @param entityMode */ private SessionImpl(SessionImpl parent, EntityMode entityMode) { super( parent.factory ); this.rootSession = parent; this.timestamp = parent.timestamp; this.jdbcContext = parent.jdbcContext; this.interceptor = parent.interceptor; this.listeners = parent.listeners; this.actionQueue = new ActionQueue( this ); this.entityMode = entityMode; this.persistenceContext = new StatefulPersistenceContext( this ); this.flushBeforeCompletionEnabled = false; this.autoCloseSessionEnabled = false; this.connectionReleaseMode = null; if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession(); } log.debug( "opened session [" + entityMode + "]" ); }
factory.getStatisticsImplementor().closeSession();
factory.getStatisticsImplementor().openSession();
factory.getStatisticsImplementor().openSession();