@OneToMany does not work with @JoinFormula
I think @OneToMany annotation does not work at all with @JoinFormula annotation.
I found some old issue https://hibernate.atlassian.net/browse/HHH-9897, but I'm not sure how to interpret it - that is whether it indeed was never supported, or that the specific case in that issue wasn't supported (i.e. with @JoinColumnsOrFormulas).
Having the following entity:
The above mapping does not work. During validation we get exception
Adding reverse side of the relationship (@ManyToOne with @JoinFormula) and adding "mappedBy" to @OneToMany does not change anything - still same error. Also it does not matter that in the attached example we have relation from table A to the same table A - I tested it with different tables with same result.
From https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html#associations-JoinFormula, it seems the annotated field should be some column field in child class. You are using it on parent class and I am almost certain such feature would never be supported, for basically the mechanism aims to provide a customized foreign key, so using it on child class’s ManyToOne field does make sense.
I don’t think Hibernate team will support @OneToMany + @JoinFormula, IMHO. I think the comment in said the same thing.
Any update here?
I’m interested as well.
Yes please, or at least an announcement about if it’s going to be ignored forever?
Any chance for some attention for this issue?