gpt4 book ai didi

java - 使用jpa持久化对象的问题

转载 作者:行者123 更新时间:2023-11-29 06:17:25 26 4
gpt4 key购买 nike

我正在使用 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 提供程序。

最佳答案

根据 this documentation你必须查看 SQL0407,它意味着:

Null values not allowed in column or variable &5.

因此,实际上,您正试图将 NULL 放入不可为 null 的列中。

关于java - 使用jpa持久化对象的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4555732/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com