Class AbstractCollectionEvent

java.lang.Object
org.hibernate.event.spi.AbstractSessionEvent
org.hibernate.event.spi.AbstractCollectionEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
InitializeCollectionEvent, PostCollectionRecreateEvent, PostCollectionRemoveEvent, PostCollectionUpdateEvent, PreCollectionRecreateEvent, PreCollectionRemoveEvent, PreCollectionUpdateEvent

public abstract class AbstractCollectionEvent extends AbstractSessionEvent
Defines a base class for events involving collections.
See Also:
API Note:
AbstractCollectionEvent and its implementations are defined as SPI for consumption; their constructors are defined as internal
  • Constructor Details

    • AbstractCollectionEvent

      @Internal public AbstractCollectionEvent(CollectionPersister collectionPersister, PersistentCollection<?> collection, EventSource source, Object owner, Object ownerId)
      Constructs an instance for a stateful session.
      Parameters:
      collectionPersister - The descriptor for the collection mapping.
      collection - - The (wrapped) collection instance.
      source - - The session
      owner - - The entity instance that "owns" the collection affected by this event; can be null if unavailable.
      ownerId - - The identifier value for the owner; can be null if unavailable.
    • AbstractCollectionEvent

      @Internal public AbstractCollectionEvent(CollectionPersister collectionPersister, PersistentCollection<?> collection, String ownerEntityName, Object owner, Object ownerId)
      Constructs an instance for a stateless session.
      Parameters:
      collectionPersister - The descriptor for the collection mapping.
      collection - - The (wrapped) collection instance.
      ownerEntityName - - The entity-name of the owner.
      owner - - The entity instance that "owns" the collection affected by this event; can be null if unavailable.
      ownerId - - The identifier value for the owner; can be null if unavailable.
  • Method Details

    • getCollectionPersister

      public CollectionPersister getCollectionPersister()
      The descriptor for the collection mapping.
    • getCollection

      public PersistentCollection<?> getCollection()
      The (wrapped) collection instance affected by this event.
    • getAffectedOwnerOrNull

      public Object getAffectedOwnerOrNull()
      Get the collection owner entity that is affected by this event.
      Returns:
      the affected owner; returns null if the entity is not in the persistence context (e.g., because the collection from a detached entity was moved to a new owner)
    • getAffectedOwnerIdOrNull

      public Object getAffectedOwnerIdOrNull()
      Get the ID for the collection owner entity that is affected by this event.
      Returns:
      the affected owner ID; returns null if the ID cannot be obtained from the collection's loaded key (e.g., a property-ref is used for the collection and does not include the entity's ID)
    • getAffectedOwnerEntityName

      public String getAffectedOwnerEntityName()
      Get the entity name for the collection owner entity that is affected by this event.
      Returns:
      the entity name; if the owner is not in the PersistenceContext, the returned value may be a superclass name, instead of the actual class name
    • getLoadedCollectionPersister

      protected static CollectionPersister getLoadedCollectionPersister(PersistentCollection<?> collection, EventSource source)
    • getLoadedOwnerOrNull

      protected static Object getLoadedOwnerOrNull(PersistentCollection<?> collection, EventSource source)
    • getLoadedOwnerIdOrNull

      protected static Object getLoadedOwnerIdOrNull(PersistentCollection<?> collection, EventSource source)
    • getOwnerIdOrNull

      protected static Object getOwnerIdOrNull(Object owner, EventSource source)
    • getAffectedOwnerEntityName

      protected static String getAffectedOwnerEntityName(CollectionPersister collectionPersister, Object affectedOwner, EventSource source)