我正在使用jpa来保存一个对象。当我试图坚持它时,我得到以下异常:
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.jdbc.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
是因为empname字段是空白的吗? COLNO = 1是指第一列(empid)还是第二列(empname)? 我使用open jpa作为jpa提供者。
答案 0 :(得分:2)
答案 1 :(得分:1)
COLNO = 1与第二列(empname)相关。您应该检查它是否为空或违反了唯一约束。