hibernate-orm
hibernate-orm copied to clipboard
HHH-15722 : @OneToMany mappedBy with a @Any
https://hibernate.atlassian.net/browse/HHH-15722 https://discourse.hibernate.org/t/onetomany-with-interface-type-return-variable-role-column-any/7050
Since the collection, which is mapped by the return variable (mappedBy) of the referenced objects, knows its type, the identifying column of the foreign key is sufficient, without having to use the discrimination column.
@startuml
class Library {
-Long id
-Set<Book> books
+void setId(Long)
+Long getId()
+Set<Book> getBooks()
+void setBooks(Set<Book>)
}
class Book {
-Long id
-Store store
+void setId(Long)
+Long getId()
+Store getStore()
+void setStore(Store)
}
interface Store {
}
Library --|> Store : implements
Library "1" -- "*" Book : contains
@enduml
Thank you very much, I'll do this as quickly as possible!
Hey @boutss, how is it going with the work on this PR?
Hey @beikov
So normally it's done.
I proposed the solution of subsequently replacing the discrimination value in the queries using the getter with replaceAnyDiscriminatorValue.
It's not the best, but since I have the information in the second pass and the query variables are final, I don't see any other solutions at the moment.
Also, I have errors in the GitHub jobs, but I don't see where to find the description of the errors?
Thanks for your pull request!
This pull request does not follow the contribution rules. Could you have a look?
❌ All commit messages should start with a JIRA issue key matching pattern HHH-\d+
↳ Offending commits: [8141a48e755a4fdbe2c89ee46630d88055143e25]
› This message was automatically generated.
Thanks for your work. I simplified and cleaned up the code. Superseded by https://github.com/hibernate/hibernate-orm/pull/8514
Good job! You now have more class variables, and you directly retrieve the discrimination value, no need to calculate the SQL query afterwards.
I'm disappointed that I didn't manage to do this. Of course, I wasn't satisfied with my solution.
You succeeded in retrieving everything from the PersistentClass; I'll remember that.
I lack knowledge of the model, but normally I could have retrieved the information if it was present and accessible. There I failed ^^ Probably because I should have focused on retrieving the PersistentClass of the associated entity, and from there, I had all the necessary information.
Thank you!