openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laird Nelson <ljnel...@gmail.com>
Subject OpenJPA does not read default schema from orm.xml for TableGenerator-specified sequence table
Date Fri, 26 Aug 2011 21:04:16 GMT
I have a @TableGenerator annotation that does not specify a schema:

@javax.persistence.TableGenerator(
    name = "Fund",
    table = "jpa_sequence",
    pkColumnName = "sequence_name",
    valueColumnName = "last_value",
    pkColumnValue = "Fund",
    allocationSize = 500
)

I have a persistence-unit-defaults stanza in my META-INF/orm.xml that DOES
specify a default schema:

<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence/orm

http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
                 version="2.0">

  <persistence-unit-metadata>
    <persistence-unit-defaults>
      <schema>ngp</schema>
    </persistence-unit-defaults>
  </persistence-unit-metadata>
</entity-mappings>

OpenJPA does not use this default schema when working with the sequence
table described by my @TableGenerator annotation.  IMHO it should.  See the
stack:

<openjpa-2.1.0-r422266:1071316 fatal general error>
org.apache.openjpa.persistence.PersistenceException: Table "JPA_SEQUENCE"
not found; SQL statement:
SELECT LAST_VALUE FROM jpa_sequence WHERE SEQUENCE_NAME = ? FOR UPDATE
[42102-151] {SELECT LAST_VALUE FROM jpa_sequence WHERE SEQUENCE_NAME = ? FOR
UPDATE} [code=42102, state=42S02]
    at
org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4869)
    at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4829)
    at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
    at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:110)
    at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:62)
    at
org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:66)
    at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160)
    at
org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144)
    at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:785)
    at
org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:493)
    at
org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:469)
    at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:769)
    at
org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:135)
    at
org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:605)
    at
org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2966)
    at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:40)
    at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1047)
    at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2091)
    at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2051)
    at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1822)
    at
org.apache.openjpa.kernel.DelegatingBroker.flush(DelegatingBroker.java:1037)
    at
org.apache.openjpa.persistence.EntityManagerImpl.flush(EntityManagerImpl.java:654)

My default schema is supposed to be "ngp".  EclipseLink works fine here (and
has for several versions).  Hibernate suffers from the same bug (
https://hibernate.onjira.com/browse/HHH-5235) and in grand Hibernate fashion
shows no signs of ever fixing it.  Should I file a bug here, or have I
misunderstood the specification?

Best,
Laird

-- 
http://about.me/lairdnelson

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message