Guillaume Toison (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZjc2ZDA4NzZj...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16744?atlOrigin=eyJpIjoiZjc2ZD...
) HHH-16744 (
https://hibernate.atlassian.net/browse/HHH-16744?atlOrigin=eyJpIjoiZjc2ZD...
) Wrong class created when reusing a join column for different entities in multiple
ManyToOne (
https://hibernate.atlassian.net/browse/HHH-16744?atlOrigin=eyJpIjoiZjc2ZD...
)
Issue Type: Bug Affects Versions: 6.2.4 Assignee: Unassigned Components: hibernate-core
Created: 03/Jun/2023 13:47 PM Priority: Major Reporter: Guillaume Toison (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3...
)
Consider the following abridged model (please note the reused food_id column and the
self-referencing @ManyToOne in Fruit and Cheese ):
class Container {
}
class FruitContainer extends Container {
@ManyToOne
@JoinColumn(name = "food_id" )
@Fetch(FetchMode.SELECT)
private Fruit fruit;
}
class CheeseContainer extends Container {
@ManyToOne
@JoinColumn(name = "food_id" )
@Fetch(FetchMode.SELECT)
private Cheese cheese;
}
class Food {
}
class Fruit extends Food {
@ManyToOne
@Fetch(FetchMode.SELECT)
private Fruit bestPairedWith;
}
class Cheese extends Food {
@ManyToOne
@Fetch(FetchMode.SELECT)
private Cheese bestPairedWith;
}
When batch-loading several Container objects, Hibernate seems to create the wrong class (a
Cheese instead of a Fruit )
I’m not sure if reusing a column in different branches of an inheritance tree is supported
but this seemed to work in Hibernate 5.
In Hibernate 6 an initializer seems to be associated with the column during the batch load
but it only works for one of the types.
(
https://hibernate.atlassian.net/browse/HHH-16744#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16744#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100225- sha1:e03cc87 )