This has got nothing to do with Spring Data JPA but is the way JPA specifies this to work (section 4.10 - "Bulk Update and Delete Operations", JPA 2.0 specification):
A delete operation only applies to entities of the specified class and its subclasses. It does not cascade to related entities.
If you think about it, JPA cascades are not database-level cascades but ones maintained by the EntityManager
. Hence, the EntityManager
needs to know about the entity instance to be deleted and its related instances. If you trigger a query, it effectively can't know about those as the persistence provider translates it into SQL and executes it. So there's no way the EntityManager
can analyze the object graph as the execution is completely happening in the database.
A question and answer related to this topic here can be found over here.