org.hibernate.event.def
Class AbstractSaveEventListener

java.lang.Object
  extended byorg.hibernate.event.def.AbstractReassociateEventListener
      extended byorg.hibernate.event.def.AbstractSaveEventListener
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DefaultMergeEventListener, DefaultPersistEventListener, DefaultReplicateEventListener, DefaultSaveOrUpdateEventListener

public abstract class AbstractSaveEventListener
extends AbstractReassociateEventListener

A convenience bas class for listeners responding to save events.

Author:
Steve Ebersole.
See Also:
Serialized Form

Field Summary
protected static int DELETED
           
protected static int DETACHED
           
protected static int PERSISTENT
           
protected static int TRANSIENT
           
 
Constructor Summary
AbstractSaveEventListener()
           
 
Method Summary
protected  void cascadeAfterSave(EventSource source, EntityPersister persister, Object entity, Object anything)
          Handles to calls needed to perform post-save cascades.
protected  void cascadeBeforeSave(EventSource source, EntityPersister persister, Object entity, Object anything)
          Handles the calls needed to perform pre-save cascades for the given entity.
protected  Boolean getAssumedUnsaved()
           
protected abstract  CascadingAction getCascadeAction()
           
protected  int getEntityState(Object entity, String entityName, EntityEntry entry, SessionImplementor source)
          Determine whether the entity is persistent, detached, or transient
protected  String getLoggableName(String entityName, Object entity)
           
protected  Map getMergeMap(Object anything)
           
protected  boolean invokeSaveLifecycle(Object entity, EntityPersister persister, EventSource source)
           
protected  boolean isVersionIncrementDisabled()
          After the save, will te version number be incremented if the instance is modified?
protected  Serializable performSave(Object entity, Serializable id, EntityPersister persister, boolean useIdentityColumn, Object anything, EventSource source)
          Ppepares the save call by checking the session caches for a pre-existing entity and performing any lifecycle callbacks.
protected  Serializable performSaveOrReplicate(Object entity, EntityKey key, EntityPersister persister, boolean useIdentityColumn, Object anything, EventSource source)
          Performs all the actual work needed to save an entity (well to get the save moved to the execution queue).
protected  Serializable saveWithGeneratedId(Object entity, String entityName, Object anything, EventSource source)
          Prepares the save call using a newly generated id.
protected  Serializable saveWithRequestedId(Object entity, Serializable requestedId, String entityName, Object anything, EventSource source)
          Prepares the save call using the given requested id.
protected  boolean substituteValuesIfNecessary(Object entity, Serializable id, Object[] values, EntityPersister persister, SessionImplementor source)
          Perform any property value substitution that is necessary (interceptor callback, version initialization...)
protected  void validate(Object entity, EntityPersister persister, EventSource source)
           
protected  boolean visitCollectionsBeforeSave(Serializable id, Object[] values, Type[] types, EventSource source)
           
 
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
 

Field Detail

PERSISTENT

protected static final int PERSISTENT
See Also:
Constant Field Values

TRANSIENT

protected static final int TRANSIENT
See Also:
Constant Field Values

DETACHED

protected static final int DETACHED
See Also:
Constant Field Values

DELETED

protected static final int DELETED
See Also:
Constant Field Values
Constructor Detail

AbstractSaveEventListener

public AbstractSaveEventListener()
Method Detail

saveWithRequestedId

protected Serializable saveWithRequestedId(Object entity,
                                           Serializable requestedId,
                                           String entityName,
                                           Object anything,
                                           EventSource source)
                                    throws HibernateException
Prepares the save call using the given requested id.

Parameters:
entity - The entity to be saved.
requestedId - The id to which to associate the entity.
source - The session which is the source of this save event.
Returns:
The id used to save the entity.
Throws:
HibernateException

saveWithGeneratedId

protected Serializable saveWithGeneratedId(Object entity,
                                           String entityName,
                                           Object anything,
                                           EventSource source)
                                    throws HibernateException
Prepares the save call using a newly generated id.

Parameters:
entity - The entity to be saved
source - The session which is the source of this save event.
Returns:
The id used to save the entity
Throws:
HibernateException

performSave

protected Serializable performSave(Object entity,
                                   Serializable id,
                                   EntityPersister persister,
                                   boolean useIdentityColumn,
                                   Object anything,
                                   EventSource source)
                            throws HibernateException
Ppepares the save call by checking the session caches for a pre-existing entity and performing any lifecycle callbacks.

Parameters:
entity - The entity to be saved.
id - The id by which to save the entity.
persister - The entity's persister instance.
useIdentityColumn - Is an identity column in use?
source - The session from which the event originated.
Returns:
The id used to save the entity.
Throws:
HibernateException

invokeSaveLifecycle

protected boolean invokeSaveLifecycle(Object entity,
                                      EntityPersister persister,
                                      EventSource source)

validate

protected void validate(Object entity,
                        EntityPersister persister,
                        EventSource source)

performSaveOrReplicate

protected Serializable performSaveOrReplicate(Object entity,
                                              EntityKey key,
                                              EntityPersister persister,
                                              boolean useIdentityColumn,
                                              Object anything,
                                              EventSource source)
                                       throws HibernateException
Performs all the actual work needed to save an entity (well to get the save moved to the execution queue).

Parameters:
entity - The entity to be saved
key - The id to be used for saving the entity (or null, in the case of identity columns)
persister - The entity's persister instance.
useIdentityColumn - Should an identity column be used for id generation?
source - The session which is the source of the current event.
Returns:
The id used to save the entity.
Throws:
HibernateException

getMergeMap

protected Map getMergeMap(Object anything)

isVersionIncrementDisabled

protected boolean isVersionIncrementDisabled()
After the save, will te version number be incremented if the instance is modified?


visitCollectionsBeforeSave

protected boolean visitCollectionsBeforeSave(Serializable id,
                                             Object[] values,
                                             Type[] types,
                                             EventSource source)

substituteValuesIfNecessary

protected boolean substituteValuesIfNecessary(Object entity,
                                              Serializable id,
                                              Object[] values,
                                              EntityPersister persister,
                                              SessionImplementor source)
Perform any property value substitution that is necessary (interceptor callback, version initialization...)


cascadeBeforeSave

protected void cascadeBeforeSave(EventSource source,
                                 EntityPersister persister,
                                 Object entity,
                                 Object anything)
                          throws HibernateException
Handles the calls needed to perform pre-save cascades for the given entity.

Parameters:
source - The session from whcih the save event originated.
persister - The entity's persister instance.
entity - The entity to be saved.
Throws:
HibernateException

cascadeAfterSave

protected void cascadeAfterSave(EventSource source,
                                EntityPersister persister,
                                Object entity,
                                Object anything)
                         throws HibernateException
Handles to calls needed to perform post-save cascades.

Parameters:
source - The session from which the event originated.
persister - The entity's persister instance.
entity - The entity beng saved.
Throws:
HibernateException

getCascadeAction

protected abstract CascadingAction getCascadeAction()

getEntityState

protected int getEntityState(Object entity,
                             String entityName,
                             EntityEntry entry,
                             SessionImplementor source)
Determine whether the entity is persistent, detached, or transient


getLoggableName

protected String getLoggableName(String entityName,
                                 Object entity)

getAssumedUnsaved

protected Boolean getAssumedUnsaved()