@NamedSubgraph referred to generic property in mapped superclass is broken

Description

I have the following class (getters/setters are omitted):

And some subclasses:

Here is CategoryEntity and VodAttributeEntity:

And VodTagEntity:

After upgrading from 5.2.12 to 5.4.1 I get the following exception when creating Hibernate SessionFactory (through JPA):
java.lang.ExceptionInInitializerError
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: sandbox] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1015)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:941)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at Test.<clinit>(Test.java:7)
Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [featured] on this ManagedType [VodAttributeEntity]
at org.hibernate.metamodel.model.domain.internal.AbstractManagedType.checkNotNull(AbstractManagedType.java:147)
at org.hibernate.metamodel.model.domain.internal.AbstractManagedType.getAttribute(AbstractManagedType.java:118)
at org.hibernate.graph.spi.GraphImplementor.findOrCreateAttributeNode(GraphImplementor.java:98)
at org.hibernate.graph.internal.AbstractGraph.addAttributeNode(AbstractGraph.java:175)
at org.hibernate.metamodel.internal.MetamodelImpl.applyNamedAttributeNodes(MetamodelImpl.java:380)
at org.hibernate.metamodel.internal.MetamodelImpl.applyNamedSubgraphs(MetamodelImpl.java:404)
at org.hibernate.metamodel.internal.MetamodelImpl.applyNamedAttributeNodes(MetamodelImpl.java:383)
at org.hibernate.metamodel.internal.MetamodelImpl.applyNamedEntityGraphs(MetamodelImpl.java:367)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:284)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:294)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:938)
... 4 more
Exception in thread "main"

Bootstrap code:

persistence.xml contains only minimal DB connection properties, and there is only hibernate-core and jdbc driver as maven project dependencies.

I did some debugging and found out that AttributeNodeImpl.internalMakeSubgraph(Class<S> subType) method behavior is changed (after upgrading from 5.2.12). Seems like it loose superclass generic information and uses meta information from Position class, and for some reason it's "entity" property has VodAttributeEntity type for both VodAttributePositionEntity and CategoryPositionEntity.

Is it desired behavior? I didn't notice any restrictions on using generic superclass as mappedsuperclass for entity subgraph in JPA 2.2 spec.

I attached test maven project that reproduce the problem.

Environment

Windows 10, JRE-8u181, hibernate-core 5.4.1.Final, PostgreSQL 9.6

Assignee

Unassigned

Reporter

Oleg Shitikov

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.12
5.3.9

Components

Affects versions

Priority

Major
Configure