NPE when specifying a member of a composite primary key as a name in the annotation @MapKey

Description

We have an entity BlocRecord with InheritanceType.JOINED having a composite primary key BlocRecordId

We have an entity FlowIn and we have a relation Map OneToMany from FlowIn to BlocRecord

As the inheritanceType is JOINED, the system will try to fetch the PersistentClass of the key speicified in the annotation @KeyName by invoking the following code

mapProperty.getPersistentClass() returns null because the field is defined in an embedded class ==> The following exception is thrown :

java.lang.NullPointerException
at org.hibernate.cfg.annotations.MapBinder.createFormulatedValue(MapBinder.java:448)
at org.hibernate.cfg.annotations.MapBinder.bindKeyFromAssociationTable(MapBinder.java:181)
at org.hibernate.cfg.annotations.MapBinder.access$000(MapBinder.java:66)
at org.hibernate.cfg.annotations.MapBinder$1.secondPass(MapBinder.java:101)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1635)
at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1603)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418)
at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87)
at org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:179)
at net.codejava.hibernate.Main.main(Main.java:15)

We didn't have this issue with Hibernate 5.1.14
A shortly test case is attached (HHH13353_TestCase)

Environment

None

Assignee

Unassigned

Reporter

BEN AHMED

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.1.14

Components

Affects versions

Priority

Major
Configure