Reputation: 857
In a JPA entity, is it redundant to have:
cascade = CascadeType.ALL, orphanRemoval = true
From my understanding orphanRemoval
is basically a more aggressive version of cascade
, so would there ever be a case when cascade
would catch something that orphanRemoval
wouldn't?
Upvotes: 1
Views: 252
Reputation: 26522
orphanRemoval
would only cover the CascadeType.REMOVE
.
If you remove the cascade = CascadeType.ALL
and leave only the orphanRemoval = true
, then you would miss out on the following operations which would not be cascaded anymore:
{PERSIST, MERGE, REFRESH, DETACH}.
Upvotes: 2