I am using jpa to persist a object. When i try to persist it i get following exception:
Create failure,Error occurred while create Chargebasis
<openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 fatal general error> org.apache.openjpa.persistence.PersistenceException: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1679)
at org.apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java:989)
at org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:592)
....
Caused by: <openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=517, COLNO=1, DRIVER=3.50.152
FailedObject: prepstmnt 154143024 INSERT INTO XYZ (empid, empname,CREATE_TS, UPDT_TS) VALUES (?, ?, ?, ?) [org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement]
at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4245)
at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4210)
at org.apache.openjpa.jdb开发者_运维技巧c.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:504)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:195)
at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:63)
..
Caused by: com.ibm.db2.jcc.b.lm: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=517, COLNO=1, DRIVER=3.50.152
Is it because empname field is blank? Does COLNO=1 refer to first(empid) or second column(empname)? I am using open jpa as jpa provider.
According to this documentation you have to look at SQL0407 and it means:
Null values not allowed in column or variable &5.
So, indeed, you're trying to put a NULL
in a non-nullable column.
COLNO = 1 is related to the second column(empname). You should check if it is empty or violates unique constraint.
精彩评论