/** * Used by JDK serialization... * * @param oos The output stream to which we are being written... * * @throws IOException Indicates a general IO stream exception */ private void writeObject(ObjectOutputStream oos) throws IOException { if ( TRACE_ENABLED ) { log.tracef( "Serializing Session [%s]", getSessionIdentifier() ); } oos.defaultWriteObject(); persistenceContext.serialize( oos ); actionQueue.serialize( oos ); oos.writeObject( loadQueryInfluencers ); }
log.tracef( "Deserializing Session [%s]", getSessionIdentifier() );
public void closeWithoutOpenChecks() throws HibernateException { if ( TRACE_ENABLED ) { log.tracef( "Closing session [%s]", getSessionIdentifier() ); } // todo : we want this check if usage is JPA, but not native Hibernate usage if ( getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) { // Original hibernate-entitymanager EM#close behavior checkSessionFactoryOpen(); checkOpenOrWaitingForAutoClose(); if ( discardOnClose || !isTransactionInProgress( false ) ) { super.close(); } else { //Otherwise, session auto-close will be enabled by shouldAutoCloseSession(). waitingForAutoClose = true; closed = true; } } else { super.close(); } if ( getFactory().getStatistics().isStatisticsEnabled() ) { getFactory().getStatistics().closeSession(); } }
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { super( factory, options ); this.actionQueue = new ActionQueue( this ); this.persistenceContext = new StatefulPersistenceContext( this ); this.sessionOwner = options.getSessionOwner(); initializeFromSessionOwner( sessionOwner ); this.autoClear = options.shouldAutoClear(); this.autoClose = options.shouldAutoClose(); this.queryParametersValidationEnabled = options.isQueryParametersValidationEnabled(); this.disallowOutOfTransactionUpdateOperations = !factory.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations(); this.discardOnClose = getFactory().getSessionFactoryOptions().isReleaseResourcesOnCloseEnabled(); if ( options instanceof SharedSessionCreationOptions && ( (SharedSessionCreationOptions) options ).isTransactionCoordinatorShared() ) { final SharedSessionCreationOptions sharedOptions = (SharedSessionCreationOptions) options; if ( sharedOptions.getTransactionCompletionProcesses() != null ) { actionQueue.setTransactionCompletionProcesses( sharedOptions.getTransactionCompletionProcesses(), true ); } } loadQueryInfluencers = new LoadQueryInfluencers( factory ); if ( getFactory().getStatistics().isStatisticsEnabled() ) { getFactory().getStatistics().openSession(); } // NOTE : pulse() already handles auto-join-ability correctly getTransactionCoordinator().pulse(); setDefaultProperties(); applyProperties(); if ( TRACE_ENABLED ) { log.tracef( "Opened Session [%s] at timestamp: %s", getSessionIdentifier(), getTimestamp() ); } }
/** * Used by JDK serialization... * * @param oos The output stream to which we are being written... * * @throws IOException Indicates a general IO stream exception */ private void writeObject(ObjectOutputStream oos) throws IOException { if ( TRACE_ENABLED ) { log.tracef( "Serializing Session [%s]", getSessionIdentifier() ); } oos.defaultWriteObject(); persistenceContext.serialize( oos ); actionQueue.serialize( oos ); oos.writeObject( loadQueryInfluencers ); }
log.tracef( "Deserializing Session [%s]", getSessionIdentifier() );
public void closeWithoutOpenChecks() throws HibernateException { if ( TRACE_ENABLED ) { log.tracef( "Closing session [%s]", getSessionIdentifier() ); } // todo : we want this check if usage is JPA, but not native Hibernate usage if ( getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) { // Original hibernate-entitymanager EM#close behavior checkSessionFactoryOpen(); checkOpenOrWaitingForAutoClose(); if ( discardOnClose || !isTransactionInProgress( false ) ) { super.close(); } else { //Otherwise, session auto-close will be enabled by shouldAutoCloseSession(). waitingForAutoClose = true; closed = true; } } else { super.close(); } if ( getFactory().getStatistics().isStatisticsEnabled() ) { getFactory().getStatistics().closeSession(); } }
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { super( factory, options ); this.actionQueue = new ActionQueue( this ); this.persistenceContext = new StatefulPersistenceContext( this ); this.sessionOwner = options.getSessionOwner(); initializeFromSessionOwner( sessionOwner ); this.autoClear = options.shouldAutoClear(); this.autoClose = options.shouldAutoClose(); this.queryParametersValidationEnabled = options.isQueryParametersValidationEnabled(); this.disallowOutOfTransactionUpdateOperations = !factory.getSessionFactoryOptions().isAllowOutOfTransactionUpdateOperations(); this.discardOnClose = getFactory().getSessionFactoryOptions().isReleaseResourcesOnCloseEnabled(); if ( options instanceof SharedSessionCreationOptions && ( (SharedSessionCreationOptions) options ).isTransactionCoordinatorShared() ) { final SharedSessionCreationOptions sharedOptions = (SharedSessionCreationOptions) options; if ( sharedOptions.getTransactionCompletionProcesses() != null ) { actionQueue.setTransactionCompletionProcesses( sharedOptions.getTransactionCompletionProcesses(), true ); } } loadQueryInfluencers = new LoadQueryInfluencers( factory ); if ( getFactory().getStatistics().isStatisticsEnabled() ) { getFactory().getStatistics().openSession(); } // NOTE : pulse() already handles auto-join-ability correctly getTransactionCoordinator().pulse(); setDefaultProperties(); applyProperties(); if ( TRACE_ENABLED ) { log.tracef( "Opened Session [%s] at timestamp: %s", getSessionIdentifier(), getTransactionStartTimestamp() ); } }