Package org.hibernate.engine.spi
Interface NaturalIdResolutions
-
- All Known Implementing Classes:
NaturalIdResolutionsImpl
public interface NaturalIdResolutionsManages the cached resolutions related to natural-id (to and from identifier)
-
-
Field Summary
Fields Modifier and Type Field Description static ObjectINVALID_NATURAL_ID_REFERENCEMarker reference used to indicate that a given natural-id is invalid
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancacheResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)Caches a natural-id-to-identifier resolution.voidcacheResolutionFromLoad(Object id, Object naturalId, EntityMappingType entityDescriptor)voidcleanupFromSynchronizations()ObjectfindCachedIdByNaturalId(Object naturalId, EntityMappingType entityDescriptor)Find the cached identifier for the given natural-idObjectfindCachedNaturalIdById(Object id, EntityMappingType entityDescriptor)Find the cached natural-id for the given identifierCollection<?>getCachedPkResolutions(EntityMappingType entityDescriptor)Find all the locally cached primary key cross-reference entries for the given entity.voidhandleEviction(Object id, Object object, EntityMappingType entityDescriptor)Called onSession.evict(java.lang.Object)to give a chance to clean up natural-id cross refs.voidhandleSynchronization(Object id, Object entity, EntityMappingType entityDescriptor)Part of the "load synchronization process".voidmanageLocalResolution(Object id, Object naturalIdValue, EntityMappingType entityDescriptor, CachedNaturalIdValueSource source)Ensures that the necessary local cross-reference exists.voidmanageSharedResolution(Object id, Object naturalId, Object previousNaturalId, EntityMappingType entityDescriptor, CachedNaturalIdValueSource source)Ensures that the necessary cross-reference exists in the L2 cacheObjectremoveLocalResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)Removes any local cross-reference, returning the previously cached value if one.ObjectremoveResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)Removes a natural-id-to-identifier resolution.voidremoveSharedResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)Removes any cross-reference from the L2 cache
-
-
-
Field Detail
-
INVALID_NATURAL_ID_REFERENCE
static final Object INVALID_NATURAL_ID_REFERENCE
Marker reference used to indicate that a given natural-id is invalid
-
-
Method Detail
-
cacheResolution
boolean cacheResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)
Caches a natural-id-to-identifier resolution. Handles both the local (transactional) and shared (second-level) caches.- Returns:
trueif a new entry was actually added;falseotherwise.
-
removeResolution
Object removeResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)
Removes a natural-id-to-identifier resolution.Handles both the local (transactional) and shared (second-level) caches.
- Returns:
- The cached values, if any. May be different from incoming values.
-
cacheResolutionFromLoad
void cacheResolutionFromLoad(Object id, Object naturalId, EntityMappingType entityDescriptor)
-
manageLocalResolution
void manageLocalResolution(Object id, Object naturalIdValue, EntityMappingType entityDescriptor, CachedNaturalIdValueSource source)
Ensures that the necessary local cross-reference exists. Specifically, this only effects the persistence-context cache, not the L2 cache
-
removeLocalResolution
Object removeLocalResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)
Removes any local cross-reference, returning the previously cached value if one.Again, this only effects the persistence-context cache, not the L2 cache
-
manageSharedResolution
void manageSharedResolution(Object id, Object naturalId, Object previousNaturalId, EntityMappingType entityDescriptor, CachedNaturalIdValueSource source)
Ensures that the necessary cross-reference exists in the L2 cache
-
removeSharedResolution
void removeSharedResolution(Object id, Object naturalId, EntityMappingType entityDescriptor)
Removes any cross-reference from the L2 cache
-
findCachedNaturalIdById
Object findCachedNaturalIdById(Object id, EntityMappingType entityDescriptor)
Find the cached natural-id for the given identifier- Returns:
- The cross-referenced natural-id values or
null
-
findCachedIdByNaturalId
Object findCachedIdByNaturalId(Object naturalId, EntityMappingType entityDescriptor)
Find the cached identifier for the given natural-id- Returns:
- The cross-referenced primary key,
INVALID_NATURAL_ID_REFERENCEornull.
-
getCachedPkResolutions
Collection<?> getCachedPkResolutions(EntityMappingType entityDescriptor)
Find all the locally cached primary key cross-reference entries for the given entity.- Returns:
- The primary keys
-
handleSynchronization
void handleSynchronization(Object id, Object entity, EntityMappingType entityDescriptor)
Part of the "load synchronization process".Responsible for maintaining cross-reference entries when natural-id values were found to have changed.
Also responsible for tracking the old values as no longer valid until the next flush because otherwise going to the database would just re-pull the old values as valid. In this responsibility,
cleanupFromSynchronizations()is the inverse process called after flush to clean up those entries.- See Also:
cleanupFromSynchronizations()
-
cleanupFromSynchronizations
void cleanupFromSynchronizations()
The clean up process ofhandleSynchronization(java.lang.Object, java.lang.Object, org.hibernate.metamodel.mapping.EntityMappingType). Responsible for cleaning up the tracking of old values as no longer valid.
-
handleEviction
void handleEviction(Object id, Object object, EntityMappingType entityDescriptor)
Called onSession.evict(java.lang.Object)to give a chance to clean up natural-id cross refs.
-
-