FileDocCategorySizeDatePackage
CascadingAction.javaAPI DocHibernate 3.2.515258Wed Sep 06 09:07:22 BST 2006org.hibernate.engine

CascadingAction

public abstract class CascadingAction extends Object
A session action that may be cascaded from parent entity to its children
author
Gavin King

Fields Summary
private static final Log
log
public static final CascadingAction
DELETE
public static final CascadingAction
LOCK
public static final CascadingAction
REFRESH
public static final CascadingAction
EVICT
public static final CascadingAction
SAVE_UPDATE
public static final CascadingAction
MERGE
public static final CascadingAction
SAVE_UPDATE_COPY
public static final CascadingAction
PERSIST
public static final CascadingAction
PERSIST_ON_FLUSH
Execute persist during flush time
public static final CascadingAction
REPLICATE
Constructors Summary
CascadingAction()
protected constructor



	// the CascadingAction contract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	  	 
	 
	
Methods Summary
public abstract voidcascade(org.hibernate.event.EventSource session, java.lang.Object child, java.lang.String entityName, java.lang.Object anything, boolean isCascadeDeleteEnabled)
Cascade the action to the child object.

param
session The session within which the cascade is occuring.
param
child The child to which cascading should be performed.
param
entityName The child's entity name
param
anything Anything ;) Typically some form of cascade-local cache which is specific to each CascadingAction type
param
isCascadeDeleteEnabled Are cascading deletes enabled.
throws
HibernateException

private static booleancollectionIsInitialized(java.lang.Object collection)

		return !(collection instanceof PersistentCollection) || ( (PersistentCollection) collection ).wasInitialized();
	
public abstract booleandeleteOrphans()
Does this action potentially extrapolate to orphan deletes?

return
True if this action can lead to deletions of orphans.

private static java.util.IteratorgetAllElementsIterator(org.hibernate.event.EventSource session, org.hibernate.type.CollectionType collectionType, java.lang.Object collection)
Given a collection, get an iterator of all its children, loading them from the database if necessary.

param
session The session within which the cascade is occuring.
param
collectionType The mapping type of the collection.
param
collection The collection instance.
return
The children iterator.



	// static helper methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	                                            	 
	   
			 
			 
			  
		return collectionType.getElementsIterator( collection, session );
	
public abstract java.util.IteratorgetCascadableChildrenIterator(org.hibernate.event.EventSource session, org.hibernate.type.CollectionType collectionType, java.lang.Object collection)
Given a collection, get an iterator of the children upon which the current cascading action should be visited.

param
session The session within which the cascade is occuring.
param
collectionType The mapping type of the collection.
param
collection The collection instance.
return
The children iterator.

public static java.util.IteratorgetLoadedElementsIterator(SessionImplementor session, org.hibernate.type.CollectionType collectionType, java.lang.Object collection)
Iterate just the elements of the collection that are already there. Don't load any new elements from the database.

		if ( collectionIsInitialized(collection) ) {
			// handles arrays and newly instantiated collections
			return collectionType.getElementsIterator(collection, session);
		}
		else {
			// does not handle arrays (thats ok, cos they can't be lazy)
			// or newly instantiated collections, so we can do the cast
			return ( (PersistentCollection) collection ).queuedAdditionIterator();
		}
	
public voidnoCascade(org.hibernate.event.EventSource session, java.lang.Object child, java.lang.Object parent, org.hibernate.persister.entity.EntityPersister persister, int propertyIndex)
Called (in the case of {@link #requiresNoCascadeChecking} returning true) to validate that no cascade on the given property is considered a valid semantic.

param
session The session witin which the cascade is occurring.
param
child The property value
param
parent The property value owner
param
persister The entity persister for the owner
param
propertyIndex The index of the property within the owner.

	
public booleanperformOnLazyProperty()
Should this action be performed (or noCascade consulted) in the case of lazy properties.

		return true;
	
public booleanrequiresNoCascadeChecking()
Does the specified cascading action require verification of no cascade validity?

return
True if this action requires no-cascade verification; false otherwise.

		return false;