@Override public void physicalConnectionObtained(Connection connection) { if (sessionFactory.getStatistics().isStatisticsEnabled()) { sessionFactory.getStatisticsImplementor().connect(); } }
@Override public void physicalConnectionObtained(Connection connection) { if (sessionFactory.getStatistics().isStatisticsEnabled()) { sessionFactory.getStatisticsImplementor().connect(); } }
@Override public void statementPrepared() { if (sessionFactory.getStatistics().isStatisticsEnabled()) { sessionFactory.getStatisticsImplementor().prepareStatement(); } } }
@Override public void statementPrepared() { if (sessionFactory.getStatistics().isStatisticsEnabled()) { sessionFactory.getStatisticsImplementor().prepareStatement(); } } }
@SuppressWarnings({"UnnecessaryBoxing"}) public void invalidate(Serializable[] spaces) throws CacheException { readWriteLock.writeLock().lock(); try { Long ts = region.nextTimestamp(); for (Serializable space : spaces) { LOG.debugf( "Invalidating space [%s], timestamp: %s", space, ts ); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync region.put( space, ts ); if ( factory != null && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().updateTimestampsCachePut(); } } } finally { readWriteLock.writeLock().unlock(); } }
@SuppressWarnings({"UnnecessaryBoxing"}) public void invalidate(Serializable[] spaces) throws CacheException { readWriteLock.writeLock().lock(); try { Long ts = region.nextTimestamp(); for (Serializable space : spaces) { LOG.debugf( "Invalidating space [%s], timestamp: %s", space, ts ); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync region.put( space, ts ); if ( factory != null && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().updateTimestampsCachePut(); } } } finally { readWriteLock.writeLock().unlock(); } }
@SuppressWarnings({"UnnecessaryBoxing"}) public void preinvalidate(Serializable[] spaces) throws CacheException { readWriteLock.writeLock().lock(); try { Long ts = region.nextTimestamp() + region.getTimeout(); for ( Serializable space : spaces ) { LOG.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts ); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync region.put( space, ts ); if ( factory != null && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().updateTimestampsCachePut(); } } } finally { readWriteLock.writeLock().unlock(); } }
@SuppressWarnings({"UnnecessaryBoxing"}) public void preinvalidate(Serializable[] spaces) throws CacheException { readWriteLock.writeLock().lock(); try { Long ts = region.nextTimestamp() + region.getTimeout(); for ( Serializable space : spaces ) { LOG.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts ); //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync region.put( space, ts ); if ( factory != null && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().updateTimestampsCachePut(); } } } finally { readWriteLock.writeLock().unlock(); } }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { final boolean put = naturalIdCacheAccessStrategy.afterUpdate( naturalIdCacheKey, pk, lock ); if ( put && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().naturalIdCachePut( naturalIdCacheAccessStrategy.getRegion().getName() ); } } }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { final boolean put = naturalIdCacheAccessStrategy.afterInsert( naturalIdCacheKey, pk ); if ( put && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().naturalIdCachePut( naturalIdCacheAccessStrategy.getRegion().getName() ); } } }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { final boolean put = naturalIdCacheAccessStrategy.afterUpdate( naturalIdCacheKey, pk, lock ); if ( put && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().naturalIdCachePut( naturalIdCacheAccessStrategy.getRegion().getName() ); } } }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { final boolean put = naturalIdCacheAccessStrategy.afterInsert( naturalIdCacheKey, pk ); if ( put && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatisticsImplementor().naturalIdCachePut( naturalIdCacheAccessStrategy.getRegion().getName() ); } } }
/** 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(); final PersistenceContext persistenceContext = source.getPersistenceContext(); if ( persistenceContext.getEntityEntries().size() > 0 || persistenceContext.getCollectionEntries().size() > 0 ) { 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(); final PersistenceContext persistenceContext = source.getPersistenceContext(); if ( persistenceContext.getEntityEntries().size() > 0 || persistenceContext.getCollectionEntries().size() > 0 ) { flushEverythingToExecutions(event); performExecutions(source); postFlush(source); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().flush(); } } } }
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 ); } return snapshot; } // TODO: optimize away this lookup for entities w/o unsaved-value="undefined" final EntityKey entityKey = session.generateEntityKey( id, persister ); return session.getPersistenceContext().getCachedDatabaseSnapshot( entityKey ); } }
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 ); } return snapshot; } // TODO: optimize away this lookup for entities w/o unsaved-value="undefined" final EntityKey entityKey = session.generateEntityKey( id, persister ); return session.getPersistenceContext().getCachedDatabaseSnapshot( entityKey ); } }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException { EntityPersister persister = getPersister(); if ( success && isCachePutEnabled( persister, getSession() ) ) { final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() ); boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() ); } } postCommitInsert(); }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException { EntityPersister persister = getPersister(); if ( success && isCachePutEnabled( persister, getSession() ) ) { final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() ); boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() ); } } postCommitInsert(); }
@Override public void execute() throws HibernateException { // this method is called when a new non-null collection is persisted // or when an existing (non-null) collection is moved to a new owner final PersistentCollection collection = getCollection(); preRecreate(); getPersister().recreate( collection, getKey(), getSession() ); getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); evict(); postRecreate(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }
@Override public void execute() throws HibernateException { // this method is called when a new non-null collection is persisted // or when an existing (non-null) collection is moved to a new owner final PersistentCollection collection = getCollection(); preRecreate(); getPersister().recreate( collection, getKey(), getSession() ); getSession().getPersistenceContext() .getCollectionEntry(collection) .afterAction(collection); evict(); postRecreate(); if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor() .recreateCollection( getPersister().getRole() ); } }