I have a DB with some foreign keys that are configured without ON DELETE CASCADE
; I'd like to avoid changing this if possible. Similarly, our JPA relationships are not configured with cascade = CascadeType.REMOVE
.
Is it still possible to delete an entity "in cascade mode", i.e. automatically generating all the necessary delete queries for its children?
Ideally I'd want to do it through JPA, but a raw SQL query would work as well. The main problem is that not all (but most) foreign key constraints are reflected with JPA relationships like OneToOne
, OneToMany
, et cetera.