Bug 383 : Bug when using jdbc batch with cascading save on OneToMany
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.7.5
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
11/03/2012
Updated 
11/03/2012
Type 
Bug
 
Attachments 
No attachments

javax.persistence.PersistenceException: Error when batch flush on sql: insert into ut_detail (utmaster_id, name, qty, amount, version) values (?,?,?,?,?)
at com.avaje.ebeaninternal.server.persist.BatchedPstmtHolder.flush(BatchedPstmtHolder.java:151)
at com.avaje.ebeaninternal.server.persist.BatchControl.flushPstmtHolder(BatchControl.java:226)
at com.avaje.ebeaninternal.server.persist.BatchControl.flush(BatchControl.java:265)
at com.avaje.ebeaninternal.server.persist.BatchControl.executeOrQueue(BatchControl.java:197)
at com.avaje.ebeaninternal.server.core.PersistRequestBean.executeOrQueue(PersistRequestBean.java:531)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:406)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveVanillaInsert(DefaultPersister.java:377)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveVanillaRecurse(DefaultPersister.java:361)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:308)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveAssocManyDetails(DefaultPersister.java:923)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveMany(DefaultPersister.java:806)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveAssocMany(DefaultPersister.java:711)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.insert(DefaultPersister.java:410)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveVanillaInsert(DefaultPersister.java:377)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveVanillaRecurse(DefaultPersister.java:361)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.saveRecurse(DefaultPersister.java:308)
at com.avaje.ebeaninternal.server.persist.DefaultPersister.save(DefaultPersister.java:282)
at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1837)
at com.avaje.ebeaninternal.server.core.DefaultServer.save(DefaultServer.java:1815)
at com.avaje.ebean.Ebean.save(Ebean.java:606)
at com.avaje.ebean.Ebean.save(Ebean.java:613)
at com.avaje.tests.batchinsert.TestBatchInsertSimple.testSimpleJdbcBatching(TestBatchInsertSimple.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.sql.BatchUpdateException: Column 'utmaster_id' cannot be null
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2024)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1449)
at com.avaje.ebeaninternal.server.lib.sql.ExtendedStatement.executeBatch(ExtendedStatement.java:132)
at com.avaje.ebeaninternal.server.persist.BatchedPstmt.executeAndCheckRowCounts(BatchedPstmt.java:146)
at com.avaje.ebeaninternal.server.persist.BatchedPstmt.executeBatch(BatchedPstmt.java:107)
at com.avaje.ebeaninternal.server.persist.BatchedPstmtHolder.flush(BatchedPstmtHolder.java:118)
... 40 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'utmaster_id' cannot be null
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
at com.mysql.jdbc.Util.getInstance(Util.java:382)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1039)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2415)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1976)
... 45 more

 
Rob 11 Mar 11:37
Fixed in HEAD.

Fixed in HEAD.

Rob 14 Mar 22:10
Note

The testcase:

https://ebeanorm.svn.sourceforge.net/svnroot/ebeanorm/ebean/trunk/src/test/java/com/avaje/tests/batchinsert/TestBatchInsertSimple.java

woResponse

Upload a file