We're upgrading from Hibernate 4.3.11 to Hibernate 5.2.7 and are getting a NullPointerException in ModelBinder when it tries to access a PrimaryKey. It's null.
We have a mix of HBM and Annotation entities. It happens when an entity is mapped via XML and references an entity that is mapped via annotations - many to one. We're using the legacy bootstrapping process via spring's LocalSessionFactoryBuilder (version 5). I've tried changing to non-legacy native bootstrapping, but that made no difference.
Here's the exception:
{code:java|title=NPE in ModelBinder} Caused by: java.lang.NullPointerException at org.hibernate.boot.model.source.internal.hbm.ModelBinder$ManyToOneColumnBinder.doSecondPass(ModelBinder.java:4140) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1576) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:691) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726) ~[hibernate-core-5.2.7.Final.jar:5.2.7.Final] at com.i2rd.hibernate.util.RebuildableSessionFactoryBean.createSessionFactory(RebuildableSessionFactoryBean.java:242) ~[net.proteusframework-core.jar:?] at com.i2rd.hibernate.util.RebuildableSessionFactoryBean.rebuildSessionFactory(RebuildableSessionFactoryBean.java:204) ~[net.proteusframework-core.jar:?] at com.i2rd.hibernate.util.RebuildableSessionFactoryBean.getObject(RebuildableSessionFactoryBean.java:182) ~[net.proteusframework-core.jar:?] at com.i2rd.hibernate.util.RebuildableSessionFactoryBean.getObject(RebuildableSessionFactoryBean.java:54) ~[net.proteusframework-core.jar:?] at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE] {code}
Originally posted here: https://forum.hibernate.org/viewtopic.php?f=1&t=1044033
I worked around it in the short-term by changing ModelBinder to create the primary key on-demand if it doesn't exist.
I'll include a test Test case shortly : https://github . com/hibernate/hibernate-orm/pull/1796
|
|