public abstract class

AbstractSaveEventListener

extends AbstractReassociateEventListener
java.lang.Object
   ↳ org.hibernate.event.def.AbstractReassociateEventListener
     ↳ org.hibernate.event.def.AbstractSaveEventListener
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A convenience bas class for listeners responding to save events.

Summary

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

Constants

protected static final int DELETED

Constant Value: 3 (0x00000003)

protected static final int DETACHED

Constant Value: 2 (0x00000002)

protected static final int PERSISTENT

Constant Value: 0 (0x00000000)

protected static final int TRANSIENT

Constant Value: 1 (0x00000001)

Public Constructors

public AbstractSaveEventListener ()

Protected Methods

protected void cascadeAfterSave (EventSource source, EntityPersister persister, Object entity, Object anything)

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.
anything Generally cascade-specific data

protected void cascadeBeforeSave (EventSource source, EntityPersister persister, Object entity, Object anything)

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.
anything Generally cascade-specific data

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

Parameters
entity The entity to check
entityName The name of the entity
entry The entity's entry in the persistence context
source The originating session.
Returns
  • The state.

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?

Returns
  • True if the version will be incremented on an entity change after save; false otherwise.

protected Serializable performSave (Object entity, Serializable id, EntityPersister persister, boolean useIdentityColumn, Object anything, EventSource source, boolean requiresImmediateIdAccess)

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 being used?
anything Generally cascade-specific information.
source The session from which the event originated.
requiresImmediateIdAccess does the event context require access to the identifier immediately after execution of this method (if not, post-insert style id generators may be postponed if we are outside a transaction).
Returns
  • The id used to save the entity; may be null depending on the type of id generator used and the requiresImmediateIdAccess value

protected Serializable performSaveOrReplicate (Object entity, EntityKey key, EntityPersister persister, boolean useIdentityColumn, Object anything, EventSource source, boolean requiresImmediateIdAccess)

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?
anything Generally cascade-specific information.
source The session which is the source of the current event.
requiresImmediateIdAccess Is access to the identifier required immediately after the completion of the save? persist(), for example, does not require this...
Returns
  • The id used to save the entity; may be null depending on the type of id generator used and the requiresImmediateIdAccess value

protected Serializable saveWithGeneratedId (Object entity, String entityName, Object anything, EventSource source, boolean requiresImmediateIdAccess)

Prepares the save call using a newly generated id.

Parameters
entity The entity to be saved
entityName The entity-name for the entity to be saved
anything Generally cascade-specific information.
source The session which is the source of this save event.
requiresImmediateIdAccess does the event context require access to the identifier immediately after execution of this method (if not, post-insert style id generators may be postponed if we are outside a transaction).
Returns
  • The id used to save the entity; may be null depending on the type of id generator used and the requiresImmediateIdAccess value

protected Serializable saveWithRequestedId (Object entity, Serializable requestedId, String entityName, Object anything, EventSource source)

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.
entityName The name of the entity being saved.
anything Generally cascade-specific information.
source The session which is the source of this save event.
Returns
  • The id used to save the entity.

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...)

Parameters
entity The entity
id The entity identifier
values The snapshot entity state
persister The entity persister
source The originating session
Returns
  • True if the snapshot state changed such that reinjection of the values into the entity is required.

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

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