On Tue, 26 Mar 2019 at 15:08, Steve Ebersole <steve(a)hibernate.org> wrote:
On Tue, Mar 26, 2019 at 9:57 AM Sanne Grinovero <sanne(a)hibernate.org> wrote:
> One question: could we benefit from "cascade delete" rules defined in
> the table structure?
> If Hibernate ORM was able parse the cascading rules from existing
> schemas, and possibly generate them for new schemas, you could have an
> entire crop of additional such optimisations. I'm not sure if I'm
> talking about material for ORM 7+ but if you could make sure that such
> future optimisations aren't ruled out that would be awesome :)
We actually do already have some limited support for cascading FKs in ORM -
`org.hibernate.annotations.OnDelete`. And it is exported to the database if defined. We
do not (nor should we) parse this information from the existing schema.
Why should we not?
What you are asking about specifically would require us to round out that support
(secondary tables at least are not yet supported) and of course to leverage that in the
HQL bulk deletion handlers. Not impossible or even particularly difficult - but enough
work that I'd rather that be handled somewhere post-6.0
+1 fair enough