> But the test cases fail, because it tries to create the sequence
> included in the schema definition:
> Could not create new "sequence" DATASTORE_SEQ since autoCreate flags
> do not allow it.
>
> Any idea why the existing sequence is not used? I double-checked the
> schema and the mapping metadata, but cannot find anything.
It is being used ... or at least trying to. Sadly when the statement
VALUES NEXT VALUE FOR DATASTORE_SEQ
is used to create a PreparedStatement, it throws an exception
07:43:42,677 (main) INFO [DataNucleus.General] - >> reserveBlock caught
exception
java.sql.SQLSyntaxErrorException: SEQUENCE 'DATASTORE_SEQ' does not exist.
at
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement40.<init>(Unknown
Source)
at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
Source)
at
com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:190)
at
org.datanucleus.store.rdbms.SQLController.getStatementForQuery(SQLController.java:327)
at
org.datanucleus.store.rdbms.SQLController.getStatementForQuery(SQLController.java:267)
at
org.datanucleus.store.rdbms.valuegenerator.SequenceGenerator.reserveBlock(SequenceGenerator.java:135)
at
org.datanucleus.store.valuegenerator.AbstractGenerator.reserveBlock(AbstractGenerator.java:305)
at
org.datanucleus.store.rdbms.valuegenerator.AbstractRDBMSGenerator.obtainGenerationBlock(AbstractRDBMSGenerator.java:101)
So the question is why does Derby not allow that statement. Maybe you need to
prefix your schema name on the sequence name ?
--
Andy
DataNucleus (http://www.datanucleus.org)