CriteriaBuilder throws an exception when trying to build a select based on an embeddedId property if the entity extends MappedSuperclass and the MappedSuperclass contains a generic embedded ID.
Issue occurs with the following mappedSuperclass for composite keys (EmbeddedId) and concrete entities implementing this abstract superclass:
Now the issue is that if multiple entities exist and I try to access an ID property of an entity with CriteriaBuilder, an exception is thrown (for all except one entity):
Seems that the metamodel maps all of my entities to the same MappedSuperclass instance. During application startup, the properties of the `@EmbeddedId` returned by `newId()` are set to the id type attributes of the MappedSupperclass, *overwriting* the id type attributes of the previous entity. So in the end, all entities are mapped to the same MappedSupperclass, but the MappedSupperclass only has the id type attributes of the last entity.
I have create a test case here.
Probably related to and (however these issues only mention issues with getting the correct type, while in my case the query creation fails).
We also stumbled upon this bug in every tested version of Hibernate 5+, even the newest for date, 5.4.4.
In Hibernate 4.3.7 it works without problem, so I see it as a regression.