0

I have a code that works perfectly on WAS 7 but fail when i run it in WAS 8.0.0.5. I am using JPA 2.0 with openJPA as my provider. Calling persist on my em throws a nested exception. Has anyone ever managed to write a JPA program in WAS 8.0.0.5

here is the Exception

WTRN0074E: Exception caught from before_completion synchronization operation: org.apache.openjpa.persistence.PersistenceException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=.OPENJPA_SEQUENCE_TABLE, DRIVER=3.58.81 {prepstmnt -1559269434 SELECT SEQUENCE_VALUE FROM .OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR READ ONLY WITH RS USE AND KEEP UPDATE LOCKS [params=?]}

Thakhani Tharage
  • 1,288
  • 16
  • 19

2 Answers2

2

The SQLCODE=-204 points that something is missing. The log keeps printing THAKHANI.OPENJPA_SEQUENCE_TABLE which makes think that maybe the table is missing. You could also check to make sure the DB2 user that JPA is using has permissions to create tables and run SELECT statements on them.

Nick Roth
  • 3,057
  • 2
  • 15
  • 15
  • When i was generating the entities from table i chose key as auto instead of identity, on persist the code was trying to get the ker from OPENJPA_SEQUENCE_TABLE which did not exist. THAKHANI is my default schema. The code is working now. Thanks. – Thakhani Tharage Mar 09 '13 at 18:00
2

I manage to resolve the problem by selecting Identity as my primary key generation mechanism when generating entities from tables. I also add the following in my persistence.xml.

<properties>
    <!-- OpenJPA specific properties -->
    <property name="openjpa.TransactionMode" value="managed"/>
    <property name="openjpa.ConnectionFactoryMode" value="managed"/>
    <property name="openjpa.jdbc.DBDictionary" value="db2"/>
    <property name="openjpa.jdbc.Schema" value=<SchemaName>/>
 </properties>
Thakhani Tharage
  • 1,288
  • 16
  • 19