org.springframework.orm.hibernate3.support

## Class IdTransferringMergeEventListener

- java.lang.Object
- - org.hibernate.event.def.AbstractReassociateEventListener
  - - org.hibernate.event.def.AbstractSaveEventListener
    - - org.hibernate.event.def.DefaultMergeEventListener
      - - org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener

- All Implemented Interfaces:
    Serializable, org.hibernate.event.MergeEventListener

      public class IdTransferringMergeEventListener
      extends org.hibernate.event.def.DefaultMergeEventListener

  Extension of Hibernate's DefaultMergeEventListener, transferring the ids of newly saved objects to the corresponding original objects (that are part of the detached object graph passed into the `merge` method).

  Transferring newly assigned ids to the original graph allows for continuing to use the original object graph, despite merged copies being registered with the current Hibernate Session. This is particularly useful for web applications that might want to store an object graph and then render it in a web view, with links that include the id of certain (potentially newly saved) objects.

  The merge behavior given by this MergeEventListener is nearly identical to TopLink's merge behavior. See PetClinic for an example, which relies on ids being available for newly saved objects: the `HibernateClinic` and `TopLinkClinic` DAO implementations both use straight merge calls, with the Hibernate SessionFactory configuration specifying an `IdTransferringMergeEventListener`.

  Typically specified as entry for LocalSessionFactoryBean's "eventListeners" map, with key "merge".

  Since:
    1.2
  Author:
    Juergen Hoeller
  See Also:
    `LocalSessionFactoryBean.setEventListeners(java.util.Map)`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from class org.hibernate.event.def.AbstractSaveEventListener

      `DELETED, DETACHED, PERSISTENT, TRANSIENT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IdTransferringMergeEventListener()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `entityIsTransient(org.hibernate.event.MergeEvent event, Map copyCache)` Hibernate 3.1 implementation of ID transferral.

    - ### Methods inherited from class org.hibernate.event.def.DefaultMergeEventListener

      `cascadeAfterSave, cascadeBeforeSave, cascadeOnMerge, copyValues, copyValues, entityIsDetached, entityIsPersistent, getAssumedUnsaved, getCascadeAction, getMergeMap, getTransientCopyCache, mergeTransientEntity, onMerge, onMerge, retryMergeTransientEntities`

    - ### Methods inherited from class org.hibernate.event.def.AbstractSaveEventListener

      `getEntityState, getLoggableName, invokeSaveLifecycle, isVersionIncrementDisabled, performSave, performSaveOrReplicate, saveWithGeneratedId, saveWithRequestedId, substituteValuesIfNecessary, validate, visitCollectionsBeforeSave`

    - ### Methods inherited from class org.hibernate.event.def.AbstractReassociateEventListener

      `reassociate`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### IdTransferringMergeEventListener

          public IdTransferringMergeEventListener()

  - ### Method Detail

    - #### entityIsTransient

          protected void entityIsTransient(org.hibernate.event.MergeEvent event,
                               Map copyCache)

      Hibernate 3.1 implementation of ID transferral.
      Overrides:
        `entityIsTransient` in class `org.hibernate.event.def.DefaultMergeEventListener`