Using have a joined hierachy with:
Base class BaseEntity
Two sub classes ChildEntity1 and ChildEntity2.
Both sub classes have a column with the same name (e.g. NAME) which is not in the BaseEntity.
Another entity OtherEntity which has a ChildEntity1 property
When doing a JQL join from OtherEntity to ChildEntity1 hibernate appears to disregard which entity the NAME column is on, and picks the one on ChildEntity2 rather than the ChildEntity1 which is specified in the query (see below).
Child Entity 1:
Child Entity 2:
Turning on Hibernate query logging logging.level.org.hibernate.SQL=DEBUG shows the query becomes:
This is incorrect. The where clause should be on baseentity1_2_.name
This seems to be a result of using the @ManyToOne(targetEntity = BaseEntity.class) which for this simple example is not required, but for many more advanced hierachies will be.
Could it be because both your child entities are using the same discriminator value?