Interface NaturalIdDataAccess

All Superinterfaces:
CachedDomainDataAccess
All Known Implementing Classes:
AbstractNaturalIdDataAccess, NaturalIdNonStrictReadWriteAccess, NaturalIdReadOnlyAccess, NaturalIdReadWriteAccess, NaturalIdTransactionalAccess

public interface NaturalIdDataAccess extends CachedDomainDataAccess
Contract for managing transactional and concurrent access to cached naturalId data. The expected call sequences related to various operations are:

Note the special case of UPDATES above. Because the cache key itself has changed here we need to remove the old entry as well

There is another usage pattern that is used to invalidate entries after a query performing "bulk" HQL/SQL operations: CachedDomainDataAccess.lockRegion() then CachedDomainDataAccess.removeAll(SharedSessionContractImplementor) then CachedDomainDataAccess.unlockRegion(SoftLock)

IMPORTANT : NaturalIds are not versioned so null will always be passed to the version parameter to:

  • Method Details

    • generateCacheKey

      Object generateCacheKey(Object naturalIdValues, EntityPersister rootEntityDescriptor, SharedSessionContractImplementor session)
      To create instances of NaturalIdCacheKey for this region, Hibernate will invoke this method exclusively so that generated implementations can generate optimised keys.
      Parameters:
      naturalIdValues - the sequence of values which unequivocally identifies a cached element on this region
      rootEntityDescriptor - the persister of the element being cached
      Returns:
      a key which can be used to identify an element unequivocally on this same region
    • getNaturalIdValues

      Object getNaturalIdValues(Object cacheKey)
      Performs reverse operation to generateCacheKey(Object, EntityPersister, SharedSessionContractImplementor), returning the original naturalIdValues.
      Parameters:
      cacheKey - key returned from generateCacheKey(Object, EntityPersister, SharedSessionContractImplementor)
      Returns:
      the sequence of values which unequivocally identifies a cached element on this region
    • insert

      boolean insert(SharedSessionContractImplementor session, Object key, Object value)
      Called afterQuery an item has been inserted (beforeQuery the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.
      Parameters:
      session - Current session
      key - The item key
      value - The item
      Returns:
      Were the contents of the cache actually changed by this operation?
      Throws:
      CacheException - Propagated from underlying cache provider
    • afterInsert

      boolean afterInsert(SharedSessionContractImplementor session, Object key, Object value)
      Called afterQuery an item has been inserted (afterQuery the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.
      Parameters:
      session - Current session
      key - The item key
      value - The item
      Returns:
      Were the contents of the cache actually changed by this operation?
      Throws:
      CacheException - Propagated from underlying cache provider
    • update

      boolean update(SharedSessionContractImplementor session, Object key, Object value)
      Called afterQuery an item has been updated (beforeQuery the transaction completes), instead of calling evict(). This method is used by "synchronous" concurrency strategies.
      Parameters:
      session - Current session
      key - The item key
      value - The item
      Returns:
      Were the contents of the cache actually changed by this operation?
      Throws:
      CacheException - Propagated from underlying cache provider
    • afterUpdate

      boolean afterUpdate(SharedSessionContractImplementor session, Object key, Object value, SoftLock lock)
      Called afterQuery an item has been updated (afterQuery the transaction completes), instead of calling release(). This method is used by "asynchronous" concurrency strategies.
      Parameters:
      session - Current session
      key - The item key
      value - The item
      lock - The lock previously obtained from CachedDomainDataAccess.lockItem(SharedSessionContractImplementor, Object, Object)
      Returns:
      Were the contents of the cache actually changed by this operation?
      Throws:
      CacheException - Propagated from underlying cache provider