Use @DeleteAll
to indicate that when an relationship is deleted, EclipseLink should use a delete all query. This typically happens if the relationship is PrivateOwned
and its owner is deleted. In that case, the members of the relationship will be deleted without reading them in.
There are no elements for this annotation.
WARNING:
Use this annotation with caution. EclipseLink will not validate whether the target entity is mapped in such a way as to allow the delete all to work.
Example 2-38 shows how to use @DeleteAll
on a relationship mapping.
Example 2-38 Using @DeleteAll Annotation
@Entity
public class Department {
...
@OneToMany(mappedBy = "department")
@PrivateOwned
@DeleteAll
public List<Equipment> getEquipment() {
return equipment;
}
...
}
Example 2-38 shows how to use the <delete-all>
element in the eclipselink-orm.xml
file.
Example 2-39 Using <delete-all> XML
<entity class="Department">
...
<attributes>
<one-to-many name="equipment" target-entity="Equipment" mapped-by="department">
<private-owned/>
<delete-all/>
</one-to-many>
...
</attributes>
</entity>
For more information, see: