Retrieve entity using entity graph not adding type in the where clause for @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
Description
Hello,
The Retrieve entity using entity graph not adding type in the where clause for @Inheritance(strategy = InheritanceType.SINGLE_TABLE).
Query generated:
Attachments
3
Activity
Show:
Mohd Salim October 30, 2023 at 9:47 AM
Edited
Indeed, logicaaly it should be @ManyToOne. But I do not see any unique constraint created by hibernate on the ZOO_ID as said in the hibernate migration guide link. So only 1 unique constraint that is on id column(primary key)
Jan Schatteman October 27, 2023 at 3:23 PM
Did you actually try this in 6.3? I’m asking because ever since 6.2 (see 6.2 migration guide) a 1-1 relationhip like the kind you modeled on zoo<->tiger will create a unique constraint on the foreign key (ZOO_ID), meaning that you cannot insert more than one animal pointing to a particular zoo, i.e. you’d not be able to also insert an elephant pointing to the same zoo as a tiger that already points to it.
I tried it out with your mappings, and that is exactly the kind of result I get. The correct way to map this is in fact with a @ManyToOne relationship on Zoo in the Tiger class.
Am I missing something, or is the example not exactly what you tested?
This aside, even when correctly mapped, it does seem that the error mentioned in still persists for entityGraphs, so I’m looking into that.
Hello,
The Retrieve entity using entity graph not adding type in the where clause for @Inheritance(strategy = InheritanceType.SINGLE_TABLE).
Query generated: