What is the difference between @OnDelete(action=OnDeleteAction.CASCADE)
and cascade=CascadeType.REMOVE
I read here: Is there an equivalent annotation for OnDelete in JPA2
that with @OnDelete(action=OnDeleteAction.CASCADE)
the cascade will be handled by the DB, while with cascade=CascadeType.REMOVE
the cascade will be handled by the ORM (Hibernate).
Could you explain what is the difference between handling by Hibernate vs handling by the DB? How is it done "by the DB"?
Also, I would like to know why should I care about the difference. I mean, why should I choose one attitude over the other.
Last question is, looking at the OnDelete javadoc I was wondering why it says nothing about what is does and why I should use it (BTW where is the inheritance path?). So where are these points documented?
1-Some database support cascade option and some databases do not :If the database support cascade then hibernate will create schema accordingly and let database to handle cascading.
2-If database handle cascade use it ,other vice hibernate have to query database and this is a performance lost.
3-No idea
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