Join alias is miscalculated when two descendant entities have same attribute name

Description

Currently we are using JOINED inheritance type. We have a specific case where 2 descendant entities have a many-to-one association with same attribute name. The problem is that Hibernate uses only first found attribute in entity hierarchy and the next one (with same name) will be ignored. Unfortunately the TREAT keyword doesn't help and the only workaround is to rename these attributes (for instance with indexes).

I found this problem at two places in AbstractEntityPersister:
1. collectAttributeDefinitions(...):5659:

2. At the end of getSubclassPropertyTableNumber(String propertyPath):

I've attached a test case which executes the following JPQL:

It leads to following SQL:

I think the key of attribute caching should contain the entity type as well and TREATing should have an effect on alias calculation.

Environment

Spring Boot - HSQL / PostgreSQL

Assignee

Unassigned

Reporter

Tamás Frankó

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure