Annotation Type CascadeOnDelete


  • @Target({METHOD,FIELD,TYPE})
    @Retention(RUNTIME)
    public @interface CascadeOnDelete
    Define the foreign key defined by the relationship to cascade the delete on the database. This means when the source object is deleted the target object will be automatically deleted by the database. This will affect DDL generation as well as runtime behavior in omitting the delete statements.

    The constraint cascaded depends on the mapping, only relationship mappings are allowed. The relationship should also use cascade remove, or deleteOrphans.

    For a OneToOne it can only be defined if the mapping uses a mappedBy, and will delete the target object.

    It cannot be defined for a ManyToOne.

    For a OneToMany it will delete the target objects, or ONLY the join table if using a join table.

    For a ManyToMany it will delete the rows from the join table, not the target objects.

    For an ElementCollection it will delete the target rows.

    For an Entity it will delete the secondary or JOINED inheritance tables.

    Author:
    James Sutherland
    Since:
    EclipseLink 2.2