public StatisticsImplementor getStatisticsImplementor() { return getCurrentSessionFactoryImplementor().getStatisticsImplementor(); }
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 static void queryExecuted(SessionFactoryImplementor sessionFactoryImplementor, String sql) { if (sessionFactoryImplementor != null && sessionFactoryImplementor.getStatistics().isStatisticsEnabled()) { StatisticsImplementor statisticsImplementor = sessionFactoryImplementor.getStatisticsImplementor(); if (statisticsImplementor instanceof SampledStatistics) { ((SampledStatistics) statisticsImplementor).incrementDBSQLExecution(); } } }
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 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); }
public void connectionOpened() { if ( owner.getFactory().getStatistics().isStatisticsEnabled() ) { owner.getFactory().getStatisticsImplementor().connect(); } }
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 connectionOpened() { if ( !isTransactionCallbackRegistered ) { // If there is no current transaction callback registered // when we obtain a connection, try to register one now. // Note that this is not going to handle the case of // multiple-transactions-per-connection when the user is // manipulating transactions (need to use Hibernate txn) registerSynchronizationIfPossible(); } if ( owner.getFactory().getStatistics().isStatisticsEnabled() ) { owner.getFactory().getStatisticsImplementor().connect(); } }
/** 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(); } } } }
/** 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(); } } } }
public void execute() throws HibernateException { getPersister().recreate( collection, getKey(), getSession() ); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }
public void execute() throws HibernateException { if ( !emptySnapshot ) getPersister().remove( getKey(), getSession() ); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .removeCollection( getPersister().getRole() ); } }
public void execute() throws HibernateException { final PersistentCollection collection = getCollection(); getPersister().recreate( collection, getKey(), getSession() ); getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }
private Object[] getDatabaseSnapshot(SessionImplementor session, EntityPersister persister, Serializable id) { if ( persister.isSelectBeforeUpdateRequired() ) { Object[] snapshot = session.getPersistenceContext() .getDatabaseSnapshot(id, persister); if (snapshot==null) { //do we even really need this? the update will fail anyway.... if ( session.getFactory().getStatistics().isStatisticsEnabled() ) { session.getFactory().getStatisticsImplementor() .optimisticFailure( persister.getEntityName() ); } throw new StaleObjectStateException( persister.getEntityName(), id ); } else { return snapshot; } } else { //TODO: optimize away this lookup for entities w/o unsaved-value="undefined" EntityKey entityKey = new EntityKey( id, persister, session.getEntityMode() ); return session.getPersistenceContext() .getCachedDatabaseSnapshot( entityKey ); } }
public void execute() throws HibernateException { if ( !emptySnapshot ) getPersister().remove( getKey(), getSession() ); final PersistentCollection collection = getCollection(); if (collection!=null) { getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); } evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .removeCollection( getPersister().getRole() ); } }
public void afterTransactionCompletion(boolean success) throws HibernateException { EntityPersister persister = getPersister(); if ( success && isCachePutEnabled( persister, getSession() ) ) { final CacheKey ck = new CacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName(), getSession().getEntityMode(), getSession().getFactory() ); boolean put = persister.getCache().afterInsert(ck, cacheEntry, version ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .secondLevelCachePut( getPersister().getCache().getRegionName() ); } } }
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() ); } }
public void afterTransactionCompletion(boolean success) throws CacheException { EntityPersister persister = getPersister(); if ( persister.hasCache() ) { final CacheKey ck = new CacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName(), getSession().getEntityMode(), getSession().getFactory() ); if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) { boolean put = persister.getCache().afterUpdate(ck, cacheEntry, nextVersion, lock ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .secondLevelCachePut( getPersister().getCache().getRegionName() ); } } else { persister.getCache().release(ck, lock ); } } postCommitUpdate(); }
public void afterTransactionCompletion(boolean success) throws CacheException { EntityPersister persister = getPersister(); if ( persister.hasCache() ) { final CacheKey ck = new CacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName(), getSession().getEntityMode(), getSession().getFactory() ); if ( success && !persister.isCacheInvalidationRequired() ) { boolean put = persister.getCache().afterUpdate(ck, cacheEntry, nextVersion, lock ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .secondLevelCachePut( getPersister().getCache().getRegionName() ); } } else { persister.getCache().release(ck, lock ); } } }
public void execute() throws HibernateException { Serializable id = getKey(); SessionImplementor session = getSession(); CollectionPersister persister = getPersister(); if ( !collection.wasInitialized() ) { if ( !collection.hasQueuedAdditions() ) throw new AssertionFailure( "no queued adds" ); //do nothing - we only need to notify the cache... } else if ( collection.empty() ) { if ( !emptySnapshot ) persister.remove( id, session ); } else if ( collection.needsRecreate( getPersister() ) ) { if ( !emptySnapshot ) persister.remove( id, session ); persister.recreate( collection, id, session ); } else { persister.deleteRows( collection, id, session ); persister.updateRows( collection, id, session ); persister.insertRows( collection, id, session ); } evict(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor(). updateCollection( getPersister().getRole() ); } }