Package org.hibernate.annotations
Enum CascadeType
- java.lang.Object
-
- java.lang.Enum<CascadeType>
-
- org.hibernate.annotations.CascadeType
-
- All Implemented Interfaces:
Serializable
,Comparable<CascadeType>
public enum CascadeType extends Enum<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 ALL
Includes all types listed here.DELETE
Deprecated.sinceSession.delete(Object)
is deprecatedDELETE_ORPHAN
Ancient versions of Hibernate treated orphan removal as a specialized type of cascade.DETACH
Equivalent toCascadeType.DETACH
.LOCK
A cascade type for thelock()
operation.MERGE
Equivalent toCascadeType.MERGE
.PERSIST
Equivalent toCascadeType.PERSIST
.REFRESH
Equivalent toCascadeType.REFRESH
.REMOVE
Equivalent toCascadeType.REMOVE
.REPLICATE
Deprecated.sinceSession.replicate(Object, ReplicationMode)
is deprecatedSAVE_UPDATE
Deprecated.sinceSession.saveOrUpdate(Object)
is deprecated
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CascadeType
valueOf(String name)
Returns the enum constant of this type with the specified name.static CascadeType[]
values()
Returns an array containing the constants of this enum type, in the 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
@Deprecated public 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
@Deprecated public static final CascadeType SAVE_UPDATE
Deprecated.sinceSession.saveOrUpdate(Object)
is deprecatedA cascade type for thesaveOrUpdate()
operation.- See Also:
Session.saveOrUpdate(Object)
-
REPLICATE
@Deprecated public static final CascadeType REPLICATE
Deprecated.sinceSession.replicate(Object, ReplicationMode)
is deprecatedA cascade type for thereplicate()
operation.
-
DELETE_ORPHAN
@Internal public 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, in the order they are declared. This method may be used to iterate over 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 match exactly an identifier used to declare an enum 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
-
-