Incorrect FK column generated/used when using @OneToMany with @Inheritance(strategy = InheritanceType.JOINED)
Description
Hi everyone. Here are some entities to demonstrate this (getters/setters omitted for brevity):
Parent entity (container):
Child (element) base class:
And element itself:
This results in the folowing statements being generated:
Note that parent_uuid column is present in both ChildBase and FirstChild. Which to my understanding is incorrect, since FirstChild should only contain columns, defined in FirstChild itself. Also, removing @OneToMany makes this additional column disappear.
Furthermore Hibernate will actually use correct column when persisting data, but incorrect one when loading. Thus failing to find any rows. This behaviour can be seen it tests that provided.
As a workaround you can use targetEntity = ChildBase.class on @OneToMany but this results in ugly things and suboptimal SQL when working with this collection, so it is far from ideal.
Hi everyone. Here are some entities to demonstrate this (getters/setters omitted for brevity):
Parent entity (container):
Child (element) base class:
And element itself:
This results in the folowing statements being generated:
Note that parent_uuid column is present in both ChildBase and FirstChild. Which to my understanding is incorrect, since FirstChild should only contain columns, defined in FirstChild itself. Also, removing @OneToMany makes this additional column disappear.
Furthermore Hibernate will actually use correct column when persisting data, but incorrect one when loading. Thus failing to find any rows. This behaviour can be seen it tests that provided.
As a workaround you can use targetEntity = ChildBase.class on @OneToMany but this results in ugly things and suboptimal SQL when working with this collection, so it is far from ideal.