Reputation: 672
I have to retrieve data from a table in db2 using jpa
after all configuration and mapping
when I try to execute a query using the entity manager I get errors don't know where is the problem exactly.
the message error :Error 500: <openjpa-2.1.1-SNAPSHOT-r422266:1141200 fatal general error> org.apache.openjpa.persistence.PersistenceException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.CATEGORIE, DRIVER=4.8.86 {prepstmnt 85179437 SELECT t0.CODE_CAT, t0.LIBELLE_CAT FROM CATEGORIE t0 } [code=-204, state=42704]SQLCA OUTPUT[Errp=SQLNQ1FC, Errd=-2145779603, 0, 0, 0, -10, 0] DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.CATEGORIE, DRIVER=4.8.86 DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;DB2ADMIN.CATEGORIE, DRIVER=4.8.86 DB2 SQL Error: SQLCODE=-727, SQLSTATE=56098, SQLERRMC=2;-204;42704;DB2ADMIN.CATEGORIE, DRIVER=4.8.86 FailedObject: select c from Categorie c [java.lang.String]
Upvotes: 1
Views: 6589
Reputation: 182
I had the same problem and i resolved it by adding Schema in my entity :
@Entity
@Table(name="MyTable", schema="MySchemaName")
public class MyClass implements Serializable {
...
}
Upvotes: 2
Reputation: 15440
From the SQLSTATE messages page, the first error (SQLCODE=-204
, SQLSTATE=42704
) is "An undefined object or constraint name was detected". The second error (SQLCODE=-727
, SQLSTATE=56098
) is "An error occurred during implicit rebind, recompile, or revalidation.", which probably stems from the -204
.
-204
usually means that either the table name is spelled wrong, or it can't find the table for some reason. I don't see a schema on the SQL generated there (SELECT t0.CODE_CAT, t0.LIBELLE_CAT FROM CATEGORIE t0
), so perhaps you need to add that.
Upvotes: 0