Hi,
I'm upgrading my application from Hibernate(4.3.11) to Hibernate (5.2.10). With Hibernate 4, I was having hibernate.order_inserts=true and hibernate.order_updates=true in my hibernate properties. But since now i upgraded to Hibernate5 facing the problem following problem :-
Code:
java.sql.BatchUpdateException: The INSERT statement conflicted with the FOREIGN KEY constraint "RP07_DTYPE_FK". The conflict occurred in database "MyDB", table "na.RP06_DTYPE", column 'ID'.
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:1178)
com.zaxxer.hikari.pool.ProxyStatement.executeBatch(ProxyStatement.java:128)
com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeBatch(HikariProxyPreparedStatement.java)
org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:111)
org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:97)
org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:147)
When i set hibernate SQL level to debug then found out that now my INSERT commands are batched on the basis of Entity Type, So it first tries to execute the INSERT COMMANDS for inverse side table so it fails with the above error.
But i set hibernate properties hibernate.order_inserts and hibernate.order_updates to
false then there is no exception like this.
I also tried to go through the Hibernate 5 documentation, Is there anything changed for these configuration, but unfortunately i find nothing.
Can you please help me to understand why is this behaviour ?
Note :- My entities are in One to Many bidirectional relationship.