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 void closePreparedStatement(PreparedStatement ps) throws SQLException { try { log.trace("closing statement"); ps.close(); if ( factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().closeStatement(); } } finally { if ( !releasing ) { // If we are in the process of releasing, no sense // checking for aggressive-release possibility. connectionManager.afterStatement(); } } }
public void connectionOpened() { if ( owner.getFactory().getStatistics().isStatisticsEnabled() ) { owner.getFactory().getStatisticsImplementor().connect(); } }
.secondLevelCachePut( getPersister().getCache().getRegionName() ); .insertEntity( getPersister().getEntityName() );
/** Handle the given flush event. * * @param event The flush event to be handled. * @throws HibernateException */ public void onFlush(FlushEvent event) throws HibernateException { final SessionImplementor source = event.getSession(); if ( source.getPersistenceContext().hasNonReadOnlyEntities() ) { flushEverythingToExecutions(event); performExecutions(source); postFlush(source); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } } }
public void afterTransactionCompletion(boolean success, Transaction tx) { log.trace( "after transaction completion" ); if ( getFactory().getStatistics().isStatisticsEnabled() ) { getFactory().getStatisticsImplementor().endTransaction(success); } connectionManager.afterTransaction(); // releaseConnectionAfterTransaction(); isTransactionCallbackRegistered = false; isHibernateTransactionActive = false; owner.afterTransactionCompletion(success, tx); }
.insertEntity( getPersister().getEntityName() );
/** * Performs the process of loading an entity from the configured * underlying datasource. * * @param event The load event * @param persister The persister for the entity being requested for load * @param keyToLoad The EntityKey representing the entity to be loaded. * @param options The load options. * @return The object loaded from the datasource, or null if not found. * @throws HibernateException */ protected Object loadFromDatasource( final LoadEvent event, final EntityPersister persister, final EntityKey keyToLoad, final LoadEventListener.LoadType options) throws HibernateException { final SessionImplementor source = event.getSession(); Object entity = persister.load( event.getEntityId(), event.getInstanceToLoad(), event.getLockMode(), source ); if ( event.isAssociationFetch() && source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().fetchEntity( event.getEntityClassName() ); } return entity; }
session.getFactory().getStatisticsImplementor().loadCollection( persister.getRole() );
source.getFactory().getStatisticsImplementor().fetchCollection( ce.getLoadedPersister().getRole() );
.deleteEntity( getPersister().getEntityName() );
.secondLevelCachePut( getPersister().getCache().getRegionName() ); .insertEntity( getPersister().getEntityName() );
source.getFactory().getStatisticsImplementor().flush();
public void afterTransactionCompletion(boolean success, Transaction tx) { log.trace( "after transaction completion" ); if ( getFactory().getStatistics().isStatisticsEnabled() ) { getFactory().getStatisticsImplementor().endTransaction(success); } connectionManager.afterTransaction(); isTransactionCallbackRegistered = false; hibernateTransaction = null; owner.afterTransactionCompletion(success, tx); }
public void execute() throws HibernateException { EntityPersister persister = getPersister(); SessionImplementor session = getSession(); Object instance = getInstance(); PreInsertEvent preEvent = new PreInsertEvent( instance, null, state, persister, session ); final boolean veto = session.getListeners().getPreInsertEventListener().onPreInsert( preEvent ); // Don't need to lock the cache here, since if someone // else inserted the same pk first, the insert would fail if ( !veto ) generatedId = persister.insert( state, instance, session ); //TODO: this bit actually has to be called after all cascades! // but since identity insert is called *synchronously*, // instead of asynchronously as other actions, it isn't /*if ( persister.hasCache() && !persister.isCacheInvalidationRequired() ) { cacheEntry = new CacheEntry(object, persister, session); persister.getCache().insert(generatedId, cacheEntry); }*/ PostInsertEvent postEvent = new PostInsertEvent( instance, generatedId, state, getPersister(), session ); session.getListeners().getPostInsertEventListener().onPostInsert( postEvent ); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() && !veto ) { getSession().getFactory().getStatisticsImplementor() .insertEntity( getPersister().getEntityName() ); } }
source.getFactory().getStatisticsImplementor().fetchEntity( event.getEntityClassName() );
session.getFactory().getStatisticsImplementor().loadCollection( persister.getRole() );
source.getFactory().getStatisticsImplementor().fetchCollection( ce.getLoadedPersister().getRole() );
.deleteEntity( getPersister().getEntityName() );
/** Handle the given flush event. * * @param event The flush event to be handled. * @throws HibernateException */ public void onFlush(FlushEvent event) throws HibernateException { final EventSource source = event.getSession(); if ( source.getPersistenceContext().hasNonReadOnlyEntities() ) { flushEverythingToExecutions(event); performExecutions(source); postFlush(source); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } } }