Enum 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, including LOCK.

    To enable cascade LOCK, use @Cascade, for example:

     @OneToMany(mappedBy="parent")
     @Cascade({PERSIST,REFRESH,REMOVE,LOCK})
     Set<Child> children;
     
    See Also:
    Cascade
    • Enum Constant Detail

      • ALL

        public static final CascadeType ALL
        Includes all types listed here. Equivalent to CascadeType.ALL.
      • PERSIST

        public static final CascadeType PERSIST
        Equivalent to CascadeType.PERSIST.
        See Also:
        EntityManager.persist(Object)
      • MERGE

        public static final CascadeType MERGE
        Equivalent to CascadeType.MERGE.
        See Also:
        EntityManager.merge(Object)
      • REMOVE

        public static final CascadeType REMOVE
        Equivalent to CascadeType.REMOVE.
        See Also:
        EntityManager.remove(Object)
      • REFRESH

        public static final CascadeType REFRESH
        Equivalent to CascadeType.REFRESH.
        See Also:
        EntityManager.refresh(Object)
      • DETACH

        public static final CascadeType DETACH
        Equivalent to CascadeType.DETACH.
        See Also:
        EntityManager.detach(Object)
      • DELETE_ORPHAN

        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).
    • 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 name
        NullPointerException - if the argument is null