I have some tables managed by Hibernate with various foreign key constraints. Cascade on delete is currently managed by Hibernate alone. For playing around with test data I
You can safely use ON DELETE CASCADE
as long as you do not have CascadeType.REMOVE
or orphanRemoval
enabled to prevent propagation of the entity removal event.
Having @OnDelete(action = OnDeleteAction.CASCADE)
on your relation will force Hibernate to generate ON DELETE CASCADE
for related foreign keys. However your Dialect
has to indicate that such relation are supported by returning true
in supportsCascadeDelete
method.
Dialect.supportsCascadeDelete()
OnDelete