EntityStatisticsImpl(EntityPersister rootEntityDescriptor) { super( () -> rootEntityDescriptor.getCacheAccessStrategy() != null ? rootEntityDescriptor.getCacheAccessStrategy().getRegion() : null ); this.rootEntityName = rootEntityDescriptor.getRootEntityName(); }
private Object getFromSharedCache( final LoadEvent event, final EntityPersister persister, SessionImplementor source) { final EntityDataAccess cache = persister.getCacheAccessStrategy(); final Object ck = cache.generateCacheKey( event.getEntityId(), persister, source.getFactory(), source.getTenantIdentifier() ); final Object ce = CacheHelper.fromSharedCache( source, ck, persister.getCacheAccessStrategy() ); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { if ( ce == null ) { source.getFactory().getStatistics().entityCacheMiss( StatsHelper.INSTANCE.getRootEntityRole( persister ), cache.getRegion().getName() ); } else { source.getFactory().getStatistics().entityCacheHit( StatsHelper.INSTANCE.getRootEntityRole( persister ), cache.getRegion().getName() ); } } return ce; }
public void basicCacheStructureTest() { EntityPersister persister = sessionFactory().getMetamodel().entityPersisters().get( Address.class.getName() ); final DomainDataRegion region = persister.getCacheAccessStrategy().getRegion();
@Override public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) throws HibernateException { final EntityPersister persister = getPersister(); if ( success && isCachePutEnabled( persister, getSession() ) ) { final EntityDataAccess cache = persister.getCacheAccessStrategy(); SessionFactoryImplementor factory = session.getFactory(); final Object ck = cache.generateCacheKey( getId(), persister, factory, session.getTenantIdentifier() ); final boolean put = cacheAfterInsert( cache, ck ); if ( put && factory.getStatistics().isStatisticsEnabled() ) { factory.getStatistics().entityCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), cache.getRegion().getName() ); } } postCommitInsert( success ); }
.entityPersister( Item.class ) .getCacheAccessStrategy() .getRegion(); final Object fromCache = region.getCacheStorageAccess().getFromCache( region.getEffectiveKeysFactory().createEntityKey(
.entityPersister( Item.class ) .getCacheAccessStrategy() .getRegion(); final Object fromCache = region.getCacheStorageAccess().getFromCache( region.getEffectiveKeysFactory().createEntityKey(
@Override public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) throws CacheException { final EntityPersister persister = getPersister(); if ( persister.canWriteToCache() ) { final EntityDataAccess cache = persister.getCacheAccessStrategy(); final Object ck = cache.generateCacheKey( getId(), persister, session.getFactory(), session.getTenantIdentifier() ); if ( success && cacheEntry != null && !persister.isCacheInvalidationRequired() && session.getCacheMode().isPutEnabled() ) { final boolean put = cacheAfterUpdate( cache, ck ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { session.getFactory().getStatistics().entityCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), getPersister().getCacheAccessStrategy().getRegion().getName() ); } } else { cache.unlockItem(session, ck, lock ); } } postCommitUpdate( success ); }
factory.getStatistics().entityCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), cache.getRegion().getName() );
factory.getStatistics().entityCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), getPersister().getCacheAccessStrategy().getRegion().getName() );
factory.getStatistics().entityCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), cache.getRegion().getName() );
EntityStatisticsImpl(EntityTypeDescriptor rootEntityDescriptor) { super( () -> rootEntityDescriptor.getHierarchy().getEntityCacheAccess() != null ? rootEntityDescriptor.getHierarchy().getEntityCacheAccess().getRegion() : null ); this.rootEntityName = rootEntityDescriptor.getEntityName(); }
private net.sf.ehcache.Cache getCache(Class clazz) throws IllegalAccessException { EntityPersister entityPersister = ((SessionFactoryImplementor) sessionFactory()).getEntityPersister(clazz.getName() ); DomainDataRegion region = entityPersister.getCacheAccessStrategy().getRegion(); Field storageAccessField = getField(region.getClass(), "storageAccess"); StorageAccess storageAccess = (StorageAccess) storageAccessField.get(region); Field cacheField = getField(storageAccess.getClass(), "cache"); return (net.sf.ehcache.Cache) cacheField.get(storageAccess); }
private Object getFromSharedCache( final LoadEvent event, final EntityTypeDescriptor entityDescriptor, SessionImplementor source) { final EntityDataAccess cacheAccess = entityDescriptor.getHierarchy().getEntityCacheAccess(); final Object ck = cacheAccess.generateCacheKey( event.getEntityId(), entityDescriptor.getHierarchy(), source.getFactory(), source.getTenantIdentifier() ); final Object ce = CacheHelper.fromSharedCache( source, ck, cacheAccess ); if ( source.getFactory().getStatistics().isStatisticsEnabled() ) { if ( ce == null ) { source.getFactory().getStatistics().entityCacheMiss( entityDescriptor.getNavigableRole(), cacheAccess.getRegion().getName() ); } else { source.getFactory().getStatistics().entityCacheHit( entityDescriptor.getNavigableRole(), cacheAccess.getRegion().getName() ); } } return ce; }
@Override public void doAfterTransactionCompletion(boolean success, SharedSessionContractImplementor session) throws HibernateException { final EntityTypeDescriptor entityDescriptor = getEntityDescriptor(); if ( success && isCachePutEnabled( entityDescriptor, getSession() ) ) { final EntityDataAccess cache = entityDescriptor.getHierarchy().getEntityCacheAccess(); final SessionFactoryImplementor factory = session.getFactory(); final Object ck = cache.generateCacheKey( getId(), entityDescriptor.getHierarchy(), factory, session.getTenantIdentifier() ); final boolean put = cacheAfterInsert( cache, ck ); if ( put && factory.getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatistics().entityCachePut( entityDescriptor.getNavigableRole(), cache.getRegion().getName() ); } } postCommitInsert( success ); }
session.getFactory().getStatistics().entityCachePut( entityDescriptor.getNavigableRole(), entityDescriptor.getHierarchy().getEntityCacheAccess().getRegion().getName() );
factory.getStatistics().entityCachePut( entityDescriptor.getNavigableRole(), cacheAccess.getRegion().getName() );
factory.getStatistics().entityCachePut( entityDescriptor.getNavigableRole(), cacheAccess.getRegion().getName() );
factory.getStatistics().entityCachePut( entityDescriptor.getNavigableRole(), entityDescriptor.getHierarchy().getEntityCacheAccess().getRegion().getName() );