protected final void evict() throws CacheException { if ( persister.hasCache() ) { final CollectionDataAccess cache = persister.getCacheAccessStrategy(); final Object ck = cache.generateCacheKey( key, persister, session.getFactory(), session.getTenantIdentifier() ); cache.remove( session, ck); } }
private void evictCachedCollections(Type[] types, Serializable id, EventSource source) throws HibernateException { for ( Type type : types ) { if ( type.isCollectionType() ) { CollectionPersister collectionPersister = source.getFactory().getMetamodel().collectionPersister( ( (CollectionType) type ).getRole() ); if ( collectionPersister.hasCache() ) { final CollectionDataAccess cache = collectionPersister.getCacheAccessStrategy(); final Object ck = cache.generateCacheKey( id, collectionPersister, source.getFactory(), source.getTenantIdentifier() ); final SoftLock lock = cache.lockItem( source, ck, null ); cache.remove( source, ck ); source.getActionQueue().registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) ); } } else if ( type.isComponentType() ) { CompositeType actype = (CompositeType) type; evictCachedCollections( actype.getSubtypes(), id, source ); } } } }
protected final void evict() throws CacheException { if ( collectionDescriptor.hasCache() ) { final CollectionDataAccess cacheAccess = collectionDescriptor.getCacheAccess(); final Object ck = cacheAccess.generateCacheKey( key, collectionDescriptor, session.getFactory(), session.getTenantIdentifier() ); cacheAccess.remove( session, ck); } }
@SuppressWarnings("unchecked") private void evictCachedCollections(List<PersistentAttributeDescriptor> persistentAttributes, Object id, EventSource source) throws HibernateException { for ( PersistentAttributeDescriptor attribute : persistentAttributes ) { if ( PluralPersistentAttribute.class.isInstance( attribute ) ) { final PersistentCollectionDescriptor collectionDescriptor = ( (PluralPersistentAttribute) attribute ).getPersistentCollectionDescriptor(); if ( collectionDescriptor.hasCache() ) { final CollectionDataAccess cache = collectionDescriptor.getCacheAccess(); final Object ck = cache.generateCacheKey( id, collectionDescriptor, source.getFactory(), source.getTenantIdentifier() ); final SoftLock lock = cache.lockItem( source, ck, null ); source.getActionQueue().registerProcess( (success, session) -> cache.unlockItem( session, ck, lock ) ); cache.remove( source, ck ); } } else if ( EmbeddedValuedNavigable.class.isInstance( attribute ) ) { EmbeddedValuedNavigable composite = (EmbeddedValuedNavigable) attribute; evictCachedCollections( composite.getEmbeddedDescriptor().getPersistentAttributes(), id, source ); } } } }