After upgrading the hibernate from 6.1.7 to 6.3.1 Final version, we get nullpointer exception while trying to persist OnetoMany mapping entity.
java.lang.NullPointerException: Cannot invoke "org.hibernate.sql.model.PreparableMutationOperation.canBeBatched(org.hibernate.engine.jdbc.batch.spi.BatchKey, int)" because "jdbcOperation" is null
at org.hibernate.engine.jdbc.mutation.internal.StandardMutationExecutorService.createExecutor(StandardMutationExecutorService.java:77) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.persister.collection.OneToManyPersister.writeIndex(OneToManyPersister.java:229) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.persister.collection.OneToManyPersister.recreate(OneToManyPersister.java:177) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.action.internal.CollectionRecreateAction.execute(CollectionRecreateAction.java:47) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:631) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:498) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:363) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1415) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1401) ~[hibernate-core-6.3.1.Final.jar:6.3.1.Final]
We are having oneToMany mapping with map in the entity.
<class name="com.demo.dao.model.UserSubstituteEntity" table="demo_user_substitute">
<composite-id name="id" class="com.demo.datatypes.identifier.GUID">
<key-property name="id" type="string" column="USER_SUBSTITUTES_ID" />
</composite-id>
<property name="fromDate" column="FROM_DATE" />
<property name="toDate" column="TO_DATE" />
<property name="active" not-null="true" column="ACTIVE" />
<one-to-one name="userAccount" property-ref="userSubstitutes" class="com.demo.dao.model.AccountUserEntity" foreign-key="FK_DEMO_SUBST_USR_ACC" fetch="join"/>
<map name="substitutes" cascade="all-delete-orphan" inverse="true" fetch="join">
<key foreign-key="FK_DEMO_SUST_DEMO_USR_SUBST">
<column name="DEMO_USER_SUBSTITUTE_ID" unique-key="UN_USER_SUBST_KEY" />
</key>
<composite-map-key class="com.demo.UMObjectDescription">
<key-property name="UMObjectId">
<column name="UM_OBJ_ID" unique-key="UN_USER_SUBST_KEY" />
</key-property>
<key-property name="internalObjectType" >
<column name="UM_OBJ_TYPE" unique-key="UN_USER_SUBST_KEY" />
</key-property>
</composite-map-key>
<one-to-many class="com.demo.dao.model.SubstituteEntity"/>
</map>
</class>
<class name="com.demo.dao.model.SubstituteEntity" table="demo_substitute">
<composite-id name="id"
class="com.demo.datatypes.identifier.GUID">
<key-property name="id" type="string" column="USER_SUBSTITUTE_ID" />
</composite-id>
<component name="substitutionFor">
<property name="internalObjectType" column="UM_OBJ_TYPE" />
<property name="UMObjectId" column="UM_OBJ_ID" />
</component>
<bag name="substitutionGroups" table="demo_subst_substitution_grps" cascade="all-delete-orphan" fetch="join">
<key column="USER_SUBSTITUTE_ID" foreign-key="FK_DEMO_SBST_GRPS_DEMO_SBST"/>
<many-to-many column="PG_ID" class="com.demo.dao.model.ASubstitutionGroupPersistentEntity" foreign-key="FK_DEMO_SUBSGRP_DEMO_SUBS"/>
</bag>
<many-to-one
name="userSubstitute"
class="com.demo.dao.model.UserSubstituteEntity"
column="DEMO_USER_SUBSTITUTE_ID"
not-null="true"
cascade="all"
foreign-key="FK_DEMO_SUBST_DEMO_USR_SUBST"
fetch="join"
/>
</class>
This null pointer occurs in the place of OneToManyPersister.java class as present in the screenshot below. This object updateRowOperation is null for this property UserSubstituteEntity.substitutes.
Is this an issue in hibernate or do we need to adapt something in the configuration mapping ?