hibernate-orm
hibernate-orm copied to clipboard
HHH-4301 Allow OnDelete on ElementCollection.
CollectionBinder#oneToMany is only for association, not for element collection:
- #scheduleSecondPass expects MappedBy, which is only available for associations;
- #detectMappedByProblem really wants to check association, because only for it JPA requires join table by default;
- #noAssociationTable cares about association again, because otherwise element won't be a persistent class;
- #bindManyToManySecondPass:
- #logManyToManySecondPass uses oneToMany only to differentiate between different collection of entities;
- #bindManyToManyInverseForeignKey is run for association only.
https://hibernate.atlassian.net/browse/HHH-4301
I'd appreciate some help understanding why derby and oracle time out, why it doesn't build for s390x (that J9 doesn't know var
?), why tidb cannot send emails.
I'd appreciate some help understanding why derby and oracle time out, why it doesn't build for s390x (that J9 doesn't know
var
?), why tidb cannot send emails.
We've had some problems lately, but those failures aren't related to your work.
This looks like a reasonable start. And this change should result in correct generation of the on delete cascade
constraint.
But I imagine that isn't quite enough. We also need to suppress execution of the SQL delete
statement to clean up the element collection when remove()
-ing its owning entity. That's going to require slightly more work (though I doubt it's difficult).
While I agree that this optimization (avoid explicit element collection deletes when FK is cascading) is a useful one, I'd prefer to implement it separately from fixing the bug. If we are to rely on particular DB configuration, we also need to teach Hibernate to verify its presence when jakarta.persistence.schema-generation.database.action
is VALIDATE
. And at this moment Hibernate doesn't even check if FK is there or not, yet alone its options.
Additionally, the effect this annotation has on 1:n will be different. It's hard to imagine all the corner cases that various inheritance strategies and further associations might produce.
@gavinking, what do you think about discussing and implementing the optimization outside this fix?
Superseded by #8375.