public class MergeContext extends Object implements Map
Session.merge(Object mergeEntity).
"Managed entity" and "managedEntity" method parameter refer to the managed entity that is
the result of merging an entity.
A merge entity can be transient, detached, or managed. If it is managed, then it must be
the same as its associated entity result.
If put(Object mergeEntity, Object managedEntity) is called, and this
MergeContext already contains an entry with a different entity as the key, but
with the same (managedEntity) value, this means that multiple entity representations
for the same persistent entity are being merged. If this happens,
EntityCopyObserver.entityCopyDetected(
Object managedEntity, Object mergeEntity1, Object mergeEntity2, org.hibernate.event.spi.EventSource)
will be called. It is up to that method to determine the property course of
action for this situation.
There are several restrictions.
keySet(),
values(), entrySet()) return an
unmodifiable view of the collection;managedEntity or
put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)
is executed and this MergeMap already contains a cross-reference for
mergeEntity, then managedEntity must be the
same as what is already associated with mergeEntity in this
MergeContext.
putAll(Map map) is executed, the previous restriction
applies to each entry in the Map;remove(Object) operation is not supported;
The only way to remove data from a MergeContext is by calling
clear();invertMap() will only contain the
managed-to-merge entity cross-reference to its "newest"
(most recently added) merge entity.The following method is intended to be used by a merge event listener (and other classes) in the same package to add a merge entity and its corresponding managed entity to a MergeContext and indicate if the merge operation is being performed on the merge entity yet.
put(Object mergeEntity, Object managedEntity, boolean isOperatedOn)
The following method is intended to be used by a merge event listener (and other
classes) in the same package to indicate whether the merge operation is being
performed on a merge entity already in the MergeContext:
setOperatedOn(Object mergeEntity, boolean isOperatedOn)| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears the MergeContext.
|
boolean |
containsKey(Object mergeEntity)
Returns true if this MergeContext contains a cross-reference for the specified merge entity
to a managed entity result.
|
boolean |
containsValue(Object managedEntity)
Returns true if this MergeContext contains a cross-reference from the specified managed entity
to a merge entity.
|
Set |
entrySet()
Returns an unmodifiable set view of the merge-to-managed entity cross-references contained in this MergeContext.
|
Object |
get(Object mergeEntity)
Returns the managed entity associated with the specified merge Entity.
|
Map |
invertMap()
Returns an unmodifiable map view of the managed-to-merge entity
cross-references.
|
boolean |
isEmpty()
Returns true if this MergeContext contains no merge-to-managed entity cross-references.
|
boolean |
isOperatedOn(Object mergeEntity)
Returns true if the listener is performing the merge operation on the specified merge entity.
|
Set |
keySet()
Returns an unmodifiable set view of the merge entities contained in this MergeContext
|
Object |
put(Object mergeEntity,
Object managedEntity)
Associates the specified merge entity with the specified managed entity result in this MergeContext.
|
void |
putAll(Map map)
Copies all of the mappings from the specified Map to this MergeContext.
|
Object |
remove(Object mergeEntity)
The remove operation is not supported.
|
int |
size()
Returns the number of merge-to-managed entity cross-references in this MergeContext
|
Collection |
values()
Returns an unmodifiable Set view of managed entities contained in this MergeContext.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic boolean containsKey(Object mergeEntity)
containsKey in interface MapmergeEntity - must be non-nullNullPointerException - if mergeEntity is nullpublic boolean containsValue(Object managedEntity)
containsValue in interface MapmanagedEntity - must be non-nullNullPointerException - if managedEntity is nullpublic Set entrySet()
entrySet in interface MapCollections.unmodifiableSet(java.util.Set)public Object get(Object mergeEntity)
get in interface MapmergeEntity - the merge entity; must be non-nullNullPointerException - if mergeEntity is nullpublic boolean isEmpty()
public Set keySet()
keySet in interface MapCollections.unmodifiableSet(java.util.Set)public Object put(Object mergeEntity, Object managedEntity)
mergeEntity when this
method is called, then managedEntity must be the same as what is already associated
with mergeEntity.
This method assumes that the merge process is not yet operating on mergeEntity.
Later when mergeEntity enters the merge process, setOperatedOn(Object, boolean)
should be called.
put in interface MapmergeEntity - the merge entity; must be non-nullmanagedEntity - the managed entity result; must be non-nullNullPointerException - if mergeEntity or managedEntity is nullIllegalArgumentException - if managedEntity is not the same as the previous
managed entity associated with merge entityIllegalStateException - if internal cross-references are out of sync,public void putAll(Map map)
map is subject to the same
restrictions as put(Object mergeEntity, Object managedEntity).
This method assumes that the merge process is not yet operating on any merge entityputAll in interface Mapmap - keys and values must be non-nullNullPointerException - if any key or value is nullIllegalArgumentException - if a key in map was already in this MergeContext
but associated value in map is different from the previous value in this MergeContext.IllegalStateException - if internal cross-references are out of sync,public Object remove(Object mergeEntity)
remove in interface MapmergeEntity - the merge entity.UnsupportedOperationException - if called.public int size()
public Collection values()
values in interface MapCollections.unmodifiableSet(java.util.Set)public boolean isOperatedOn(Object mergeEntity)
mergeEntity - the merge entity; must be non-nullNullPointerException - if mergeEntity is nullpublic Map invertMap()
Collections.unmodifiableMap(java.util.Map)Copyright © 2022 JBoss by Red Hat. All rights reserved.