/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * Copyright (c) 2008-2011, Red Hat Inc. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.  All third-party contributions are
 * distributed under license by Red Hat Inc.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.hibernate.cache.spi.access;

import org.hibernate.cache.CacheException;
import org.hibernate.cache.spi.EntityRegion;

Contract for managing transactional and concurrent access to cached entity data. The expected call sequences related to various operations are:

There is another usage pattern that is used to invalidate entries after performing "bulk" HQL/SQL operations: RegionAccessStrategy.lockRegion -> RegionAccessStrategy.removeAll -> RegionAccessStrategy.unlockRegion
Author:Gavin King, Steve Ebersole
/** * Contract for managing transactional and concurrent access to cached entity * data. The expected call sequences related to various operations are:<ul> * <li><b>INSERTS</b> : {@link #insert} -> {@link #afterInsert}</li> * <li><b>UPDATES</b> : {@link #lockItem} -> {@link #update} -> {@link #afterUpdate}</li> * <li><b>DELETES</b> : {@link #lockItem} -> {@link #remove} -> {@link #unlockItem}</li> * <li><b>LOADS</b> : {@link @putFromLoad}</li> * </ul> * <p/> * There is another usage pattern that is used to invalidate entries * after performing "bulk" HQL/SQL operations: * {@link #lockRegion} -> {@link #removeAll} -> {@link #unlockRegion} * * @author Gavin King * @author Steve Ebersole */
public interface EntityRegionAccessStrategy extends RegionAccessStrategy{
Get the wrapped entity cache region
Returns:The underlying region
/** * Get the wrapped entity cache region * * @return The underlying region */
public EntityRegion getRegion();
Called after an item has been inserted (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.
Params:
  • key – The item key
  • value – The item
  • version – The item's version value
Throws:
Returns:Were the contents of the cache actual changed by this operation?
/** * Called after an item has been inserted (before the transaction completes), * instead of calling evict(). * This method is used by "synchronous" concurrency strategies. * * @param key The item key * @param value The item * @param version The item's version value * @return Were the contents of the cache actual changed by this operation? * @throws CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region} */
public boolean insert(Object key, Object value, Object version) throws CacheException;
Called after an item has been inserted (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.
Params:
  • key – The item key
  • value – The item
  • version – The item's version value
Throws:
Returns:Were the contents of the cache actual changed by this operation?
/** * Called after an item has been inserted (after the transaction completes), * instead of calling release(). * This method is used by "asynchronous" concurrency strategies. * * @param key The item key * @param value The item * @param version The item's version value * @return Were the contents of the cache actual changed by this operation? * @throws CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region} */
public boolean afterInsert(Object key, Object value, Object version) throws CacheException;
Called after an item has been updated (before the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.
Params:
  • key – The item key
  • value – The item
  • currentVersion – The item's current version value
  • previousVersion – The item's previous version value
Throws:
Returns:Were the contents of the cache actual changed by this operation?
/** * Called after an item has been updated (before the transaction completes), * instead of calling evict(). This method is used by "synchronous" concurrency * strategies. * * @param key The item key * @param value The item * @param currentVersion The item's current version value * @param previousVersion The item's previous version value * @return Were the contents of the cache actual changed by this operation? * @throws CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region} */
public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException;
Called after an item has been updated (after the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.
Params:
  • key – The item key
  • value – The item
  • currentVersion – The item's current version value
  • previousVersion – The item's previous version value
  • lock – The lock previously obtained from RegionAccessStrategy.lockItem
Throws:
Returns:Were the contents of the cache actual changed by this operation?
/** * Called after an item has been updated (after the transaction completes), * instead of calling release(). This method is used by "asynchronous" * concurrency strategies. * * @param key The item key * @param value The item * @param currentVersion The item's current version value * @param previousVersion The item's previous version value * @param lock The lock previously obtained from {@link #lockItem} * @return Were the contents of the cache actual changed by this operation? * @throws CacheException Propogated from underlying {@link org.hibernate.cache.spi.Region} */
public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) throws CacheException; }