We're updating the issue view to help you get more done. 

NPE in AbstractPropertyMapping.getCommonPersistentClass when creating UnionSubclassEntityPersister for dynamic-map

Description

I use some entities of dynamic-map mode in program.
After upgrading hibernate from 5.2.13 to 5.2.14 / 5.2.15 / 5.2.16 / 5.2.17, an NPE occurs while creating SessionFactory:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Caused by: org.hibernate.MappingException: Could not instantiate persister org.hibernate.persister.entity.UnionSubclassEntityPersister at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:112) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:129) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:300) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:535) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:519) ~[spring-orm-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.4.RELEASE.jar:5.0.4.RELEASE] ... 119 common frames omitted Caused by: java.lang.NullPointerException: null at org.hibernate.persister.entity.AbstractPropertyMapping.getCommonPersistentClass(AbstractPropertyMapping.java:272) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.AbstractPropertyMapping.getCommonType(AbstractPropertyMapping.java:247) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.AbstractPropertyMapping.addPropertyPath(AbstractPropertyMapping.java:208) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.AbstractPropertyMapping.initPropertyPaths(AbstractPropertyMapping.java:330) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.AbstractEntityPersister.initOrdinaryPropertyPaths(AbstractEntityPersister.java:2314) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.AbstractEntityPersister.initPropertyPaths(AbstractEntityPersister.java:2361) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.AbstractEntityPersister.postConstruct(AbstractEntityPersister.java:3940) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:213) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_102] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_102] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_102] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_102] at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final] ... 129 common frames omitted

The HBM file to reproduce the error:

Environment

None

Status

Assignee

Andrea Boriero

Reporter

凯斌黄

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.2.13

Components

Affects versions

5.2.17
5.2.15
5.2.16
5.2.14

Priority

Major