/** * 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 + "]" ); }
/** * Constructor used for openSession(...) processing, as well as construction * of sessions for getCurrentSession(). * * @param connection The user-supplied connection to use for this session. * @param factory The factory from which this session was obtained * @param autoclose NOT USED * @param timestamp The timestamp for this session * @param interceptor The interceptor to be applied to this session * @param entityMode The entity-mode for this session * @param flushBeforeCompletionEnabled Should we auto flush before completion of transaction * @param autoCloseSessionEnabled Should we auto close after completion of transaction * @param connectionReleaseMode The mode by which we should release JDBC connections. */ SessionImpl( final Connection connection, final SessionFactoryImpl factory, final boolean autoclose, final long timestamp, final Interceptor interceptor, final EntityMode entityMode, final boolean flushBeforeCompletionEnabled, final boolean autoCloseSessionEnabled, final ConnectionReleaseMode connectionReleaseMode) { super( factory ); this.rootSession = null; this.timestamp = timestamp; this.entityMode = entityMode; this.interceptor = interceptor; this.listeners = factory.getEventListeners(); this.actionQueue = new ActionQueue( this ); this.persistenceContext = new StatefulPersistenceContext( this ); this.flushBeforeCompletionEnabled = flushBeforeCompletionEnabled; this.autoCloseSessionEnabled = autoCloseSessionEnabled; this.connectionReleaseMode = connectionReleaseMode; this.jdbcContext = new JDBCContext( this, connection, interceptor ); if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().openSession(); } if ( log.isDebugEnabled() ) { log.debug( "opened session at timestamp: " + timestamp ); } }
/** * Get the limit for the hibernate executions queue */ public int getHibernateMaxExecutions() { return ActionQueue.getMAX_EXECUTIONS_SIZE(); }
/** * Set the limit for the hibernate executions queue * Less than zero always uses event amalgamation */ public void setHibernateMaxExecutions(int hibernateMaxExecutions) { ActionQueue.setMAX_EXECUTIONS_SIZE(hibernateMaxExecutions); }
public ActionQueue getActionQueue() { errorIfClosed(); checkTransactionSynchStatus(); return actionQueue; }
/** * Used by JDK serialization... * * @param ois The input stream from which we are being read... * @throws IOException Indicates a general IO stream exception * @throws ClassNotFoundException Indicates a class resolution issue */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { log.trace( "deserializing session" ); boolean isRootSession = ois.readBoolean(); connectionReleaseMode = ConnectionReleaseMode.parse( ( String ) ois.readObject() ); entityMode = EntityMode.parse( ( String ) ois.readObject() ); autoClear = ois.readBoolean(); flushMode = FlushMode.parse( ( String ) ois.readObject() ); cacheMode = CacheMode.parse( ( String ) ois.readObject() ); flushBeforeCompletionEnabled = ois.readBoolean(); autoCloseSessionEnabled = ois.readBoolean(); fetchProfile = ( String ) ois.readObject(); interceptor = ( Interceptor ) ois.readObject(); factory = SessionFactoryImpl.deserialize( ois ); listeners = factory.getEventListeners(); if ( isRootSession ) { jdbcContext = JDBCContext.deserialize( ois, this, interceptor ); } persistenceContext = StatefulPersistenceContext.deserialize( ois, this ); actionQueue = ActionQueue.deserialize( ois, this ); enabledFilters = ( Map ) ois.readObject(); childSessionsByEntityMode = ( Map ) ois.readObject(); Iterator iter = enabledFilters.values().iterator(); while ( iter.hasNext() ) { ( ( FilterImpl ) iter.next() ).afterDeserialize(factory); } if ( isRootSession && childSessionsByEntityMode != null ) { iter = childSessionsByEntityMode.values().iterator(); while ( iter.hasNext() ) { final SessionImpl child = ( ( SessionImpl ) iter.next() ); child.rootSession = this; child.jdbcContext = this.jdbcContext; } } }
/** * Get the ActionQueue for this session */ public ActionQueue getActionQueue();