openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <>
Subject [jira] Created: (OPENJPA-67) Bug with creating a named Sequence Generator for DB2
Date Tue, 24 Oct 2006 18:40:16 GMT
Bug with creating a named Sequence Generator for DB2

                 Key: OPENJPA-67
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
         Environment: DB2
            Reporter: Kevin Sutter
         Assigned To: Kevin Sutter

We discovered that the usage of a named Sequence Generator with DB2 doesn't work as expected:

public class OrderEntity implements Serializable {
	@SequenceGenerator(name="OrderSeq", sequenceName="O_SEQ")
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="OrderSeq")
	private int orderid;

This results in the following error:

2188  TRACE  [main] openjpa.jdbc.SQL - <t 11372121, conn 27778511> [985 ms] executing
prepstmnt 3860801 SELECT NEXTVAL FOR O_SEQ
2188  TRACE  [main] openjpa.jdbc.JDBC - <t 11372121, conn 27778511> [0 ms] commit
2203  TRACE  [main] openjpa.jdbc.JDBC - <t 11372121, conn 27778511> [15 ms] close
<0|false|0.9.0-incubating-SNAPSHOT> org.apache.openjpa.persistence.PersistenceException:
An unexpected token "END-OF-STATEMENT" was found following "CT NEXTVAL FOR O_SEQ".  Expected
tokens may include:  "<table_expr>". {prepstmnt 3860801 SELECT NEXTVAL FOR O_SEQ} [code=-104,
	at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(
	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
	at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(

We have discovered that the incorrect SQL statement is specified in the DB2Dictionary.  Instead
of this:

        nextSequenceQuery = "SELECT NEXT VALUE FOR{0}";

We need this:

        nextSequenceQuery = "VALUES NEXTVAL FOR {0}";

I just wanted to document this issue instead of just fixing it so that the problem can be
searchable (we've had a few people run into this when using OpenJPA with DB2).


This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message