FileDocCategorySizeDatePackage
CascadeStyle.javaAPI DocHibernate 3.2.56963Mon Nov 13 12:34:44 GMT 2006org.hibernate.engine

CascadeStyle

public abstract class CascadeStyle extends Object implements Serializable
A contract for defining the aspects of cascading various persistence actions.
see
CascadingAction
author
Gavin King

Fields Summary
public static final CascadeStyle
ALL_DELETE_ORPHAN
save / delete / update / evict / lock / replicate / merge / persist + delete orphans
public static final CascadeStyle
ALL
save / delete / update / evict / lock / replicate / merge / persist
public static final CascadeStyle
UPDATE
save / update
public static final CascadeStyle
LOCK
lock
public static final CascadeStyle
REFRESH
refresh
public static final CascadeStyle
EVICT
evict
public static final CascadeStyle
REPLICATE
replicate
public static final CascadeStyle
MERGE
merge
public static final CascadeStyle
PERSIST
create
public static final CascadeStyle
DELETE
delete
public static final CascadeStyle
DELETE_ORPHAN
delete + delete orphans
public static final CascadeStyle
NONE
no cascades
static final Map
STYLES
Constructors Summary
CascadeStyle()
package-protected constructor


	  	 
	 
	
Methods Summary
public abstract booleandoCascade(CascadingAction action)
For this style, should the given action be cascaded?

param
action The action to be checked for cascade-ability.
return
True if the action should be cascaded under this style; false otherwise.

public static org.hibernate.engine.CascadeStylegetCascadeStyle(java.lang.String cascade)
Factory method for obtaining named cascade styles

param
cascade The named cascade style name.
return
The appropriate CascadeStyle


	 
		STYLES.put( "all", ALL );
		STYLES.put( "all-delete-orphan", ALL_DELETE_ORPHAN );
		STYLES.put( "save-update", UPDATE );
		STYLES.put( "persist", PERSIST );
		STYLES.put( "merge", MERGE );
		STYLES.put( "lock", LOCK );
		STYLES.put( "refresh", REFRESH );
		STYLES.put( "replicate", REPLICATE );
		STYLES.put( "evict", EVICT );
		STYLES.put( "delete", DELETE );
		STYLES.put( "remove", DELETE ); // adds remove as a sort-of alias for delete...
		STYLES.put( "delete-orphan", DELETE_ORPHAN );
		STYLES.put( "none", NONE );
	
		CascadeStyle style = (CascadeStyle) STYLES.get(cascade);
		if (style==null) {
			throw new MappingException("Unsupported cascade style: " + cascade);
		}
		else {
			return style;
		}	
	
public booleanhasOrphanDelete()
Do we need to delete orphaned collection elements?

return
True if this style need to account for orphan delete operations; false othwerwise.

		return false;
	
public booleanreallyDoCascade(CascadingAction action)
Probably more aptly named something like doCascadeToCollectionElements(); it is however used from both the collection and to-one logic branches...

For this style, should the given action really be cascaded? The default implementation is simply to return {@link #doCascade}; for certain styles (currently only delete-orphan), however, we need to be able to control this seperately.

param
action The action to be checked for cascade-ability.
return
True if the action should be really cascaded under this style; false otherwise.

		return doCascade(action);