org.hibernate.event.spi.EventSource#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,
org.hibernate.event.spi.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.
MergeContext#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:
MergeContext#setOperatedOn(Object mergeEntity, boolean isOperatedOn)
| Modifier and Type | Field and Description |
|---|---|
| private final EntityCopyObserver | |
| private static final Logger | |
| private Map | |
| private Map | |
| private Map | |
| private final EventSource | session
Deprecated
as a consequence of
EventSource being deprecated.
|
| Access | Constructor and Description |
|---|---|
| public | MergeContext(EventSource session, EntityCopyObserver entityCopyObserver)
Deprecated
as a consequence of
EventSource being deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | Returns: true if this MergeContext contains a cross-reference for the specified merge entitymust be non-null mergeEntity)Implements java. |
| public boolean | Returns: true if this MergeContext contains a cross-reference from the specified managed entity to a merge entitymust be non-null managedEntity)Implements java. |
| public Set | Returns: an unmodifiable set view of the merge-to-managed entity cross-references contained in this MergeContextImplements java. |
| public Object | Returns: the managed entity associated with the specified merge Entitythe merge entity; must be non-null mergeEntity)Implements java. |
| public Map | Returns: an unmodifiable map view of the managed-to-merge entity cross-references.Returns an unmodifiable map view of the managed-to-merge entity cross-references. |
| public boolean | Returns: true if this MergeContext contains no merge-to-managed entity cross-references.Implements java. |
| public boolean | Returns: true if the listener is performing the merge operation on the specified merge entity; false, if there is no mapping for mergeEntity.the merge entity; must be non-null mergeEntity)Returns true if the listener is performing the merge operation on the specified merge entity. |
| public Set | Returns: an unmodifiable set view of the merge entities contained in this MergeContextImplements java. |
| private String | |
| public Object | Returns: previous managed entity associated with specified merge entity, or null if there was no mapping for mergeEntity.the merge entity; must be non-null mergeEntity, Object the managed entity result; must be non-null managedEntity)Implements java. |
| public Object | Returns: previous managed entity associated with specified merge entity, or null if there was no mapping for mergeEntity.the merge entity; must be non-null mergeEntity, Object the managed entity; must be non-null managedEntity, boolean indicates if the merge operation is performed on the mergeEntity. isOperatedOn)Associates the specified merge entity with the specified managed entity in this MergeContext. |
| public void | putAll(Map<K, V>
keys and values must be non-null map)Implements java. |
| public Object | remove(Object
the merge entity. mergeEntity)Implements java. |
| public void | setOperatedOn(Object
must be non-null and this MergeContext must contain a cross-reference for mergeEntity
to a managed entity mergeEntity, boolean isOperatedOn)Set flag to indicate if the listener is performing the merge operation on the specified merge entity. |
| public int | Returns: the number of merge-to-managed entity cross-references in this MergeContextImplements java. |
| public Collection | Returns: an unmodifiable Set view of managed entities contained in this MergeContextImplements java. |
| entityCopyObserver | back to summary |
|---|---|
| private final EntityCopyObserver entityCopyObserver | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| managedToMergeEntityXref | back to summary |
|---|---|
| private Map<Object, Object> managedToMergeEntityXref | |
| mergeEntityToOperatedOnFlagMap | back to summary |
|---|---|
| private Map<Object, Boolean> mergeEntityToOperatedOnFlagMap | |
| mergeToManagedEntityXref | back to summary |
|---|---|
| private Map<Object, Object> mergeToManagedEntityXref | |
| session | back to summary |
|---|---|
| private final EventSource session
Deprecated as a consequence of | |
| MergeContext | back to summary |
|---|---|
| public MergeContext(EventSource session, EntityCopyObserver entityCopyObserver)
Deprecated as a consequence of | |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Clears the MergeContext. | |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object mergeEntity) Implements java. Returns true if this MergeContext contains a cross-reference for the specified merge entity to a managed entity result.
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object managedEntity) Implements java. Returns true if this MergeContext contains a cross-reference from the specified managed entity to a merge entity.
| |
| entrySet | back to summary |
|---|---|
| public Set Implements java. Returns an unmodifiable set view of the merge-to-managed entity cross-references contained in this MergeContext.
| |
| get | back to summary |
|---|---|
| public Object get(Object mergeEntity) Implements java. Returns the managed entity associated with the specified merge Entity.
| |
| invertMap | back to summary |
|---|---|
| public Map Returns an unmodifiable map view of the managed-to-merge entity cross-references. The returned Map will contain a cross-reference from each managed entity to the most recently associated merge entity that was most recently put in the MergeContext.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements java. Returns true if this MergeContext contains no merge-to-managed entity cross-references.
| |
| isOperatedOn | back to summary |
|---|---|
| public boolean isOperatedOn(Object mergeEntity) Returns true if the listener is performing the merge operation on the specified merge entity.
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Returns an unmodifiable set view of the merge entities contained in this MergeContext
| |
| printEntity | back to summary |
|---|---|
| private String printEntity(Object entity) | |
| put | back to summary |
|---|---|
| public Object put(Object mergeEntity, Object managedEntity) Implements java. Associates the specified merge entity with the specified managed entity result in this MergeContext.
If this MergeContext already contains a cross-reference for
This method assumes that the merge process is not yet operating on
| |
| put | back to summary |
|---|---|
| public Object put(Object mergeEntity, Object managedEntity, boolean isOperatedOn) Associates the specified merge entity with the specified managed entity in this MergeContext.
If this MergeContext already contains a cross-reference for
| |
| putAll | back to summary |
|---|---|
| public void putAll(Map<K, V> map) Implements java. Copies all of the mappings from the specified Map to this MergeContext.
The key and value for each entry in
| |
| remove | back to summary |
|---|---|
| public Object remove(Object mergeEntity) Implements java. The remove operation is not supported.
| |
| setOperatedOn | back to summary |
|---|---|
| public void setOperatedOn(Object mergeEntity, boolean isOperatedOn) Set flag to indicate if the listener is performing the merge operation on the specified merge entity.
| |
| size | back to summary |
|---|---|
| public int size() Implements java. Returns the number of merge-to-managed entity cross-references in this MergeContext
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Returns an unmodifiable Set view of managed entities contained in this MergeContext.
| |