org.hibernate.event.def

Class DefaultSaveOrUpdateEventListener

Implemented Interfaces:
SaveOrUpdateEventListener, Serializable
Known Direct Subclasses:
DefaultSaveEventListener, DefaultUpdateEventListener

public class DefaultSaveOrUpdateEventListener
extends AbstractSaveEventListener
implements SaveOrUpdateEventListener

Defines the default listener used by Hibernate for handling save-update events.
Authors:
Steve Ebersole
Gavin King

Field Summary

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

DELETED, DETACHED, PERSISTENT, TRANSIENT

Method Summary

protected void
entityIsDetached(SaveOrUpdateEvent event)
The given save-update event named a detached entity.
protected Serializable
entityIsPersistent(SaveOrUpdateEvent event)
protected Serializable
entityIsTransient(SaveOrUpdateEvent event)
The given save-update event named a transient entity.
protected CascadingAction
getCascadeAction()
protected Serializable
getUpdateId(Object entity, EntityPersister persister, Serializable requestedId, EntityMode entityMode)
Determine the id to use for updating.
protected boolean
invokeUpdateLifecycle(Object entity, EntityPersister persister, EventSource source)
void
onSaveOrUpdate(SaveOrUpdateEvent event)
Handle the given update event.
protected Serializable
performSaveOrUpdate(SaveOrUpdateEvent event)
protected void
performUpdate(SaveOrUpdateEvent event, Object entity, EntityPersister persister)
protected boolean
reassociateIfUninitializedProxy(Object object, SessionImplementor source)
protected Serializable
saveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
Save the transient instance, assigning the right identifier

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

cascadeAfterSave, cascadeBeforeSave, getAssumedUnsaved, getCascadeAction, getEntityState, getLoggableName, getMergeMap, invokeSaveLifecycle, isVersionIncrementDisabled, performSave, performSaveOrReplicate, saveWithGeneratedId, saveWithRequestedId, substituteValuesIfNecessary, validate, visitCollectionsBeforeSave

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

reassociate

Method Details

entityIsDetached

protected void entityIsDetached(SaveOrUpdateEvent event)
The given save-update event named a detached entity.

Here, we will perform the update processing.

Parameters:
event - The update event to be handled.

entityIsPersistent

protected Serializable entityIsPersistent(SaveOrUpdateEvent event)
            throws HibernateException

entityIsTransient

protected Serializable entityIsTransient(SaveOrUpdateEvent event)
The given save-update event named a transient entity.

Here, we will perform the save processing.

Parameters:
event - The save event to be handled.
Returns:
The entity's identifier after saving.

getCascadeAction

protected CascadingAction getCascadeAction()
Overrides:
getCascadeAction in interface AbstractSaveEventListener

getUpdateId

protected Serializable getUpdateId(Object entity,
                                   EntityPersister persister,
                                   Serializable requestedId,
                                   EntityMode entityMode)
Determine the id to use for updating.
Parameters:
entity - The entity.
persister - The entity persister
requestedId - The requested identifier
entityMode - The entity mode.
Returns:
The id.

invokeUpdateLifecycle

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

onSaveOrUpdate

public void onSaveOrUpdate(SaveOrUpdateEvent event)
Handle the given update event.
Specified by:
onSaveOrUpdate in interface SaveOrUpdateEventListener
Parameters:
event - The update event to be handled.

performSaveOrUpdate

protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event)

performUpdate

protected void performUpdate(SaveOrUpdateEvent event,
                             Object entity,
                             EntityPersister persister)
            throws HibernateException

reassociateIfUninitializedProxy

protected boolean reassociateIfUninitializedProxy(Object object,
                                                  SessionImplementor source)

saveWithGeneratedOrRequestedId

protected Serializable saveWithGeneratedOrRequestedId(SaveOrUpdateEvent event)
Save the transient instance, assigning the right identifier
Parameters:
event - The initiating event.
Returns:
The entity's identifier value after saving.