org.hibernate.engine.spi.PersistenceContext -level 2-way cross-reference (xref) between the
identifiers and natural ids of entities associated with the PersistenceContext.
Most operations resolve the proper NaturalIdResolutionCache to use based on the persister and
simply delegate calls there.
| Modifier and Type | Class and Description |
|---|---|
| private static class | NaturalIdXrefDelegate.CachedNaturalId
Used to put natural id values into collections. |
| private static class | NaturalIdXrefDelegate.NaturalIdResolutionCache
Represents the persister-specific cross-reference cache. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Logger | |
| private final ConcurrentHashMap | |
| private final StatefulPersistenceContext |
| Access | Constructor and Description |
|---|---|
| public | NaturalIdXrefDelegate(StatefulPersistenceContext
The persistence context that owns this delegate persistenceContext)Constructs a NaturalIdXrefDelegate |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if a new entry was actually added; false otherwise.The persister representing the entity type. persister, Serializable The primary key value pk, Object[] The natural id value(s) naturalIdValues)Creates needed cross-reference entries between the given primary (pk) and natural (naturalIdValues) key values for the given persister. |
| public void | |
| public Object[] | Returns: The corresponding cross-referenced natural id values, ornull if noneThe persister representing the entity type. persister, Serializable The entity primary key pk)Given a persister and primary key, find the locally cross-referenced natural id. |
| public Serializable | Returns: The corresponding cross-referenced primary key,PersistenceContext.,
or null if noneThe persister representing the entity type. persister, Object[] The natural id value(s) naturalIdValues)Given a persister and natural-id value(s), find the locally cross-referenced primary key. |
| public Collection | Returns: The primary keysThe persister representing the entity type. persister)Return all locally cross-referenced primary keys for the given persister. |
| protected EntityPersister | Returns: The root persister.The persister representing the entity type. persister)It is only valid to define natural ids at the root of an entity hierarchy. |
| public Object[] | Returns: The cached values, if any. May be different from incoming values.The persister representing the entity type. persister, Serializable The primary key value pk, Object[] The natural id value(s) naturalIdValues)Handle removing cross reference entries for the given natural-id/pk combo |
| public boolean | Returns: true if the given naturalIdValues match the current cached values; false otherwise.The persister representing the entity type. persister, Serializable The primary key value pk, Object[] The natural id value(s) to check naturalIdValues)Are the naturals id values cached here (if any) for the given persister+pk combo the same as the given values? |
| protected SharedSessionContractImplementor | Returns: The sessionAccess to the session (via the PersistenceContext) to which this delegate ultimately belongs. |
| public void | stashInvalidNaturalIdReference(EntityPersister
The persister representing the entity type. persister, Object[] The "old" natural id values. invalidNaturalIdValues)As part of "load synchronization process", if a particular natural id is found to have changed we need to track its invalidity until after the next flush. |
| public void | unStashInvalidNaturalIdReferences()
Again, as part of "load synchronization process" we need to also be able to clear references to these known-invalid natural-ids after flush. |
| protected void | validateNaturalId(EntityPersister
The persister representing the entity type. persister, Object[] The natural id values naturalIdValues)Invariant validate of the natural id. Checks include
|
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| naturalIdResolutionCacheMap | back to summary |
|---|---|
| private final ConcurrentHashMap<EntityPersister, NaturalIdXrefDelegate. | |
| persistenceContext | back to summary |
|---|---|
| private final StatefulPersistenceContext persistenceContext | |
| NaturalIdXrefDelegate | back to summary |
|---|---|
| public NaturalIdXrefDelegate(StatefulPersistenceContext persistenceContext) Constructs a NaturalIdXrefDelegate
| |
| cacheNaturalIdCrossReference | back to summary |
|---|---|
| public boolean cacheNaturalIdCrossReference(EntityPersister persister, Serializable pk, Object[] naturalIdValues) Creates needed cross-reference entries between the given primary (pk) and natural (naturalIdValues) key values
for the given persister. Returns an indication of whether entries were actually made. If those values already
existed as an entry,
| |
| clear | back to summary |
|---|---|
| public void clear() Clear the resolution cache | |
| findCachedNaturalId | back to summary |
|---|---|
| public Object[] findCachedNaturalId(EntityPersister persister, Serializable pk) Given a persister and primary key, find the locally cross-referenced natural id.
| |
| findCachedNaturalIdResolution | back to summary |
|---|---|
| public Serializable findCachedNaturalIdResolution(EntityPersister persister, Object[] naturalIdValues) Given a persister and natural-id value(s), find the locally cross-referenced primary key. Will return
| |
| getCachedPkResolutions | back to summary |
|---|---|
| public Collection Return all locally cross-referenced primary keys for the given persister. Used as part of load synchronization process.
| |
| locatePersisterForKey | back to summary |
|---|---|
| protected EntityPersister locatePersisterForKey(EntityPersister persister) It is only valid to define natural ids at the root of an entity hierarchy. This method makes sure we are using the root persister.
| |
| removeNaturalIdCrossReference | back to summary |
|---|---|
| public Object[] removeNaturalIdCrossReference(EntityPersister persister, Serializable pk, Object[] naturalIdValues) Handle removing cross reference entries for the given natural-id/pk combo
| |
| sameAsCached | back to summary |
|---|---|
| public boolean sameAsCached(EntityPersister persister, Serializable pk, Object[] naturalIdValues) Are the naturals id values cached here (if any) for the given persister+pk combo the same as the given values?
| |
| session | back to summary |
|---|---|
| protected SharedSessionContractImplementor session() Access to the session (via the PersistenceContext) to which this delegate ultimately belongs.
| |
| stashInvalidNaturalIdReference | back to summary |
|---|---|
| public void stashInvalidNaturalIdReference(EntityPersister persister, Object[] invalidNaturalIdValues) As part of "load synchronization process", if a particular natural id is found to have changed we need to track its invalidity until after the next flush. This method lets the "load synchronization process" indicate when it has encountered such changes.
| |
| unStashInvalidNaturalIdReferences | back to summary |
|---|---|
| public void unStashInvalidNaturalIdReferences() Again, as part of "load synchronization process" we need to also be able to clear references to these known-invalid natural-ids after flush. This method exposes that capability. | |
| validateNaturalId | back to summary |
|---|---|
| protected void validateNaturalId(EntityPersister persister, Object[] naturalIdValues) Invariant validate of the natural id. Checks include
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final Type[] | |
| private final EntityPersister | |
| private final Object[] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. |
| public Object[] | |
| public int | |
| private boolean |
| hashCode | back to summary |
|---|---|
| private int hashCode | |
| naturalIdTypes | back to summary |
|---|---|
| private final Type[] naturalIdTypes | |
| persister | back to summary |
|---|---|
| private final EntityPersister persister | |
| values | back to summary |
|---|---|
| private final Object[] values | |
| CachedNaturalId | back to summary |
|---|---|
| public CachedNaturalId(EntityPersister persister, Object[] values) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getValues | back to summary |
|---|---|
| public Object[] getValues() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for the object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| isSame | back to summary |
|---|---|
| private boolean isSame(Object[] otherValues) | |
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private Map | |
| private final EntityPersister | |
| private Map |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public boolean | |
| public EntityPersister | |
| public boolean | |
| public void | |
| public void |
| invalidNaturalIdList | back to summary |
|---|---|
| private List<NaturalIdXrefDelegate. | |
| naturalIdToPkMap | back to summary |
|---|---|
| private Map<NaturalIdXrefDelegate. | |
| persister | back to summary |
|---|---|
| private final EntityPersister persister | |
| pkToNaturalIdMap | back to summary |
|---|---|
| private Map<Serializable, NaturalIdXrefDelegate. | |
| NaturalIdResolutionCache | back to summary |
|---|---|
| private NaturalIdResolutionCache(EntityPersister persister) | |
| cache | back to summary |
|---|---|
| public boolean cache(Serializable pk, Object[] naturalIdValues) | |
| containsInvalidNaturalIdReference | back to summary |
|---|---|
| public boolean containsInvalidNaturalIdReference(Object[] naturalIdValues) | |
| getPersister | back to summary |
|---|---|
| public EntityPersister getPersister() | |
| sameAsCached | back to summary |
|---|---|
| public boolean sameAsCached(Serializable pk, Object[] naturalIdValues) | |
| stashInvalidNaturalIdReference | back to summary |
|---|---|
| public void stashInvalidNaturalIdReference(Object[] invalidNaturalIdValues) | |
| unStashInvalidNaturalIdReferences | back to summary |
|---|---|
| public void unStashInvalidNaturalIdReferences() | |