Relation in embedded id is not initialized when using fetch join

Description

Imagine the following example

with the following query

The attached example shows that the relation base in the embedded id PolymorphicIdRelationId is not properly initialized with the real instance, but instead a proxy although I am using a fetch join in the query.
This is especially problematic when the type of the relation is just a base type in an inheritance hierarchy.
Note that I also tested duplicating the base relation to the entity PolymorphicIdRelation, but that didn't help either. The duplicate was initialized with a proxy too, although I was join fetching that entity relation instead of the relation within the id!

The only thing that actually worked was converting the relation base in the embedded id into a basic attribute(Long baseId in my case) and map the relation with insertable and updatable set to false on the entity level.

Environment

None

Assignee

Unassigned

Reporter

Christian Beikov

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