org.hibernate.event
Class AbstractCollectionEvent

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

public abstract class AbstractCollectionEvent
extends AbstractEvent

Defines a base class for events involving collections.

Author:
Gail Badner
See Also:
Serialized Form

Constructor Summary
AbstractCollectionEvent(CollectionPersister collectionPersister, PersistentCollection collection, EventSource source, Object affectedOwner, Serializable affectedOwnerId)
          Constructs an AbstractCollectionEvent object.
 
Method Summary
 String getAffectedOwnerEntityName()
          Get the entity name for the collection owner entity that is affected by this event.
protected static String getAffectedOwnerEntityName(CollectionPersister collectionPersister, Object affectedOwner, EventSource source)
           
 Serializable getAffectedOwnerIdOrNull()
          Get the ID for the collection owner entity that is affected by this event.
 Object getAffectedOwnerOrNull()
          Get the collection owner entity that is affected by this event.
 PersistentCollection getCollection()
           
protected static CollectionPersister getLoadedCollectionPersister(PersistentCollection collection, EventSource source)
           
protected static Serializable getLoadedOwnerIdOrNull(PersistentCollection collection, EventSource source)
           
protected static Object getLoadedOwnerOrNull(PersistentCollection collection, EventSource source)
           
protected static Serializable getOwnerIdOrNull(Object owner, EventSource source)
           
 
Methods inherited from class org.hibernate.event.AbstractEvent
getSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCollectionEvent

public AbstractCollectionEvent(CollectionPersister collectionPersister,
                               PersistentCollection collection,
                               EventSource source,
                               Object affectedOwner,
                               Serializable affectedOwnerId)
Constructs an AbstractCollectionEvent object.

Parameters:
collection - - the collection
source - - the Session source
affectedOwner - - the owner that is affected by this event; can be null if unavailable
affectedOwnerId - - the ID for the owner that is affected by this event; can be null if unavailable that is affected by this event; can be null if unavailable
Method Detail

getLoadedCollectionPersister

protected static CollectionPersister getLoadedCollectionPersister(PersistentCollection collection,
                                                                  EventSource source)

getLoadedOwnerOrNull

protected static Object getLoadedOwnerOrNull(PersistentCollection collection,
                                             EventSource source)

getLoadedOwnerIdOrNull

protected static Serializable getLoadedOwnerIdOrNull(PersistentCollection collection,
                                                     EventSource source)

getOwnerIdOrNull

protected static Serializable getOwnerIdOrNull(Object owner,
                                               EventSource source)

getAffectedOwnerEntityName

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

getCollection

public PersistentCollection getCollection()

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 Serializable 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


Copyright © 2009 Hibernate.org. All Rights Reserved.