@Override public CacheKey generateCacheKey(Serializable id, Type type, String entityOrRoleName) { return session.generateCacheKey(id, type, entityOrRoleName); }
public CacheKey generateCacheKey(Serializable id, Type type, String entityOrRoleName) { return ((SessionImplementor) delegate).generateCacheKey(id, type, entityOrRoleName); }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { final CacheKey ck = session.generateCacheKey( key, persister.getKeyType(), persister.getRole() ); persister.getCacheAccessStrategy().unlockItem( ck, lock ); } }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) { final CacheKey ck = session.generateCacheKey( key, persister.getKeyType(), persister.getRole() ); persister.getCacheAccessStrategy().unlockItem( ck, lock ); } }
protected final void evict() throws CacheException { if ( persister.hasCache() ) { CacheKey ck = session.generateCacheKey( key, persister.getKeyType(), persister.getRole() ); persister.getCacheAccessStrategy().remove( ck ); } }
protected final void evict() throws CacheException { if ( persister.hasCache() ) { CacheKey ck = session.generateCacheKey( key, persister.getKeyType(), persister.getRole() ); persister.getCacheAccessStrategy().remove( ck ); } }
@Override public final void beforeExecutions() throws CacheException { // we need to obtain the lock before any actions are executed, since this may be an inverse="true" // bidirectional association and it is one of the earlier entity actions which actually updates // the database (this action is responsible for second-level cache invalidation only) if ( persister.hasCache() ) { final CacheKey ck = session.generateCacheKey( key, persister.getKeyType(), persister.getRole() ); final SoftLock lock = persister.getCacheAccessStrategy().lockItem( ck, null ); // the old behavior used key as opposed to getKey() afterTransactionProcess = new CacheCleanupProcess( key, persister, lock ); } }
@Override public final void beforeExecutions() throws CacheException { // we need to obtain the lock before any actions are executed, since this may be an inverse="true" // bidirectional association and it is one of the earlier entity actions which actually updates // the database (this action is responsible for second-level cache invalidation only) if ( persister.hasCache() ) { final CacheKey ck = session.generateCacheKey( key, persister.getKeyType(), persister.getRole() ); final SoftLock lock = persister.getCacheAccessStrategy().lockItem( ck, null ); // the old behavior used key as opposed to getKey() afterTransactionProcess = new CacheCleanupProcess( key, persister, lock ); } }
private boolean isCached(Serializable collectionKey, CollectionPersister persister) { if ( persister.hasCache() ) { CacheKey cacheKey = context.getSession().generateCacheKey( collectionKey, persister.getKeyType(), persister.getRole() ); return persister.getCacheAccessStrategy().get( cacheKey, context.getSession().getTimestamp() ) != null; } return false; } }
private boolean isCached(Serializable collectionKey, CollectionPersister persister) { if ( persister.hasCache() ) { CacheKey cacheKey = context.getSession().generateCacheKey( collectionKey, persister.getKeyType(), persister.getRole() ); return persister.getCacheAccessStrategy().get( cacheKey, context.getSession().getTimestamp() ) != null; } return false; } }
private boolean isCached(EntityKey entityKey, EntityPersister persister) { if ( persister.hasCache() ) { CacheKey key = context.getSession().generateCacheKey( entityKey.getIdentifier(), persister.getIdentifierType(), entityKey.getEntityName() ); return persister.getCacheAccessStrategy().get( key, context.getSession().getTimestamp() ) != null; } return false; }
private boolean isCached(EntityKey entityKey, EntityPersister persister) { if ( persister.hasCache() ) { CacheKey key = context.getSession().generateCacheKey( entityKey.getIdentifier(), persister.getIdentifierType(), entityKey.getEntityName() ); return persister.getCacheAccessStrategy().get( key, context.getSession().getTimestamp() ) != null; } return false; }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException { if ( getPersister().hasCache() ) { final CacheKey ck = getSession().generateCacheKey( getId(), getPersister().getIdentifierType(), getPersister().getRootEntityName() ); getPersister().getCacheAccessStrategy().unlockItem( ck, lock ); } postCommitDelete(); }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws HibernateException { if ( getPersister().hasCache() ) { final CacheKey ck = getSession().generateCacheKey( getId(), getPersister().getIdentifierType(), getPersister().getRootEntityName() ); getPersister().getCacheAccessStrategy().unlockItem( ck, lock ); } postCommitDelete(); }
@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(); }
public Object initializeLazyProperty(String fieldName, Object entity, SessionImplementor session) throws HibernateException { final Serializable id = session.getContextEntityIdentifier( entity ); final EntityEntry entry = session.getPersistenceContext().getEntry( entity ); if ( entry == null ) { throw new HibernateException( "entity is not associated with the session: " + id ); } if ( LOG.isTraceEnabled() ) { LOG.tracev( "Initializing lazy properties of: {0}, field access: {1}", MessageHelper.infoString( this, id, getFactory() ), fieldName ); } if ( hasCache() ) { CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getEntityName() ); Object ce = getCacheAccessStrategy().get( cacheKey, session.getTimestamp() ); if (ce!=null) { CacheEntry cacheEntry = (CacheEntry) getCacheEntryStructure().destructure(ce, factory); if ( !cacheEntry.areLazyPropertiesUnfetched() ) { //note early exit here: return initializeLazyPropertiesFromCache( fieldName, entity, session, entry, cacheEntry ); } } } return initializeLazyPropertiesFromDatastore( fieldName, entity, session, id, entry ); }
public Object initializeLazyProperty(String fieldName, Object entity, SessionImplementor session) throws HibernateException { final Serializable id = session.getContextEntityIdentifier( entity ); final EntityEntry entry = session.getPersistenceContext().getEntry( entity ); if ( entry == null ) { throw new HibernateException( "entity is not associated with the session: " + id ); } if ( LOG.isTraceEnabled() ) { LOG.tracev( "Initializing lazy properties of: {0}, field access: {1}", MessageHelper.infoString( this, id, getFactory() ), fieldName ); } if ( hasCache() ) { CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getEntityName() ); Object ce = getCacheAccessStrategy().get( cacheKey, session.getTimestamp() ); if (ce!=null) { CacheEntry cacheEntry = (CacheEntry) getCacheEntryStructure().destructure(ce, factory); if ( !cacheEntry.areLazyPropertiesUnfetched() ) { //note early exit here: return initializeLazyPropertiesFromCache( fieldName, entity, session, entry, cacheEntry ); } } } return initializeLazyPropertiesFromDatastore( fieldName, entity, session, id, entry ); }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws CacheException { EntityPersister persister = getPersister(); if ( persister.hasCache() ) { final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() ); if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) { boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() ); } } else { persister.getCacheAccessStrategy().unlockItem( ck, lock ); } } postCommitUpdate(); }
@Override public void doAfterTransactionCompletion(boolean success, SessionImplementor session) throws CacheException { EntityPersister persister = getPersister(); if ( persister.hasCache() ) { final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() ); if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) { boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock ); if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) { getSession().getFactory().getStatisticsImplementor().secondLevelCachePut( getPersister().getCacheAccessStrategy().getRegion().getName() ); } } else { persister.getCacheAccessStrategy().unlockItem( ck, lock ); } } postCommitUpdate(); }