At first I've expected that with CascadeType.REMOVE
I'll be able to delete foreign keys in my table , but I sill got an exception. But with @CascadeOnDelete
it's ok .What's the difference between the two annotations?
EDIT: I've saw the DataNucleus' comment.Cascade on delete comes from org.eclipse.persistence.annotations.CascadeOnDelete
.Which raises the question how good idea is to be used.
3. CascadeType. REMOVE. As stated earlier, marking a reference field with CascadeType. REMOVE is a way to delete a child entity or entities whenever the deletion of its parent happens.
Remove and Delete are defined quite similarly, but the main difference between them is that delete means erase (i.e. rendered nonexistent or nonrecoverable), while remove denotes take away and set aside (but kept in existence).
When you use CascadeType.Remove at the time the cascading will be handled by the ORM tool but when you want the cascading to be handled by the database you can use @CascadeOnDelete.but when you are using @CascadeOnDelete , make sure the Database you are using should support cascading.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With