Package org.hibernate.annotations
Enum CascadeType
- java.lang.Object
- java.lang.Enum<CascadeType>
- org.hibernate.annotations.CascadeType
- All Implemented Interfaces:
Serializable,Comparable<CascadeType>
public enumCascadeTypeextendsEnum<CascadeType>
Enumerates the persistence operations which may be cascaded from one entity instance to associated entity instances.This enumeration of cascade types competes with the JPA-defined enumeration
CascadeType, but offers additional options, includingLOCK.To enable cascade
LOCK, use@Cascade, for example:@OneToMany(mappedBy="parent") @Cascade({PERSIST,REFRESH,REMOVE,LOCK}) Set<Child> children;- See Also:
Cascade
Enum Constant Summary
Enum Constants Enum Constant Description ALLIncludes all types listed here.DELETEDeprecated.sinceSession.delete(Object)is deprecatedDELETE_ORPHANAncient versions of Hibernate treated orphan removal as a specialized type of cascade.DETACHEquivalent toCascadeType.DETACH.LOCKA cascade type for thelock()operation.MERGEEquivalent toCascadeType.MERGE.PERSISTEquivalent toCascadeType.PERSIST.REFRESHEquivalent toCascadeType.REFRESH.REMOVEEquivalent toCascadeType.REMOVE.REPLICATEDeprecated.sinceSession.replicate(Object, ReplicationMode)is deprecatedSAVE_UPDATEDeprecated.sinceSession.saveOrUpdate(Object)is deprecated
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description staticCascadeTypevalueOf(String name)Returns the enum constant of this type with the specified name.staticCascadeType[]values()Returns an array containing the constants of this enum type, inthe order they are declared.
Enum Constant Detail
ALL
public static final CascadeType ALL
Includes all types listed here. Equivalent toCascadeType.ALL.
PERSIST
public static final CascadeType PERSIST
Equivalent toCascadeType.PERSIST.- See Also:
EntityManager.persist(Object)
MERGE
public static final CascadeType MERGE
Equivalent toCascadeType.MERGE.- See Also:
EntityManager.merge(Object)
REMOVE
public static final CascadeType REMOVE
Equivalent toCascadeType.REMOVE.- See Also:
EntityManager.remove(Object)
REFRESH
public static final CascadeType REFRESH
Equivalent toCascadeType.REFRESH.- See Also:
EntityManager.refresh(Object)
DETACH
public static final CascadeType DETACH
Equivalent toCascadeType.DETACH.- See Also:
EntityManager.detach(Object)
LOCK
public static final CascadeType LOCK
A cascade type for thelock()operation.This cascade type has no equivalent in JPA.
- See Also:
Session.lock(Object, LockMode)
DELETE
@Deprecatedpublic static final CascadeType DELETE
Deprecated.sinceSession.delete(Object)is deprecatedA cascade type for thedelete()operation.This is actually a synonym for
REMOVE.- See Also:
Session.delete(Object)
SAVE_UPDATE
@Deprecatedpublic static final CascadeType SAVE_UPDATE
Deprecated.sinceSession.saveOrUpdate(Object)is deprecatedA cascade type for thesaveOrUpdate()operation.- See Also:
Session.saveOrUpdate(Object)
REPLICATE
@Deprecatedpublic static final CascadeType REPLICATE
Deprecated.sinceSession.replicate(Object, ReplicationMode)is deprecatedA cascade type for thereplicate()operation.
DELETE_ORPHAN
@Internalpublic static final CascadeType DELETE_ORPHAN
Ancient versions of Hibernate treated orphan removal as a specialized type of cascade. But since JPA 1.0, orphan removal is considered a completely separate setting, and may be enabled by annotating a one-to-one or one-to-many association@OneToOne(orphanRemoval=true)or@OneToMany(orphanRemoval=true).- API Note:
- This is now valid only for internal usage.
Method Detail
values
public static CascadeType[] values()
Returns an array containing the constants of this enum type, inthe order they are declared. This method may be used to iterateover the constants as follows:for (CascadeType c : CascadeType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
valueOf
public static CascadeType valueOf(String name)
Returns the enum constant of this type with the specified name.The string must matchexactly an identifier used to declare anenum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null