Please take a look through this[1] old post. It looks quite similar. [1] http://openjpa.markmail.org/thread/okfgmc2ldwkxrst6
Thanks, Rick On Thu, Mar 3, 2011 at 11:54 AM, kojak <[email protected]> wrote: > Hi, > > I am using Apache Derby with OpenJPA and have a class with a named query. > Unfortunately, every time I attempt to execute the named query I get an > error because OpenJPA is assuming the "USER" schema. The "USER" schema is > not the default for Derby. It is "APP" I think. This does not happen when > I do not use a named query. > > Here are my persistence.xml properties: > > openjpa.ConnectionURL=jdbc:derby:databases/JPATest;create=true > openjpa.ConnectionUserName=user > openjpa.ConnectionPassword=password > > openjpa.ConnectionDriverName=org.apache.derby.jdbc.EmbeddedDriver > openjpa.jdbc.Schema=APP > > > openjpa.jdbc.SynchronizeMappings=buildSchema(SchemaAction='add,deleteTableContents') > > > Here is my first test with a native query... > > @Entity > @NamedNativeQuery(name = "getByID", > resultClass = com.mycompany.Employee.class, > query = "SELECT x FROM Employee x WHERE x.id = ?1") > @Cacheable > @Table(schema = "APP") > public class Employee{ > > Here is the code to execute the query: > Query q = em.createNamedQuery("getByID"); > q.setParameter(1, rand); > > Here is the error: > Exception in thread "main" > org.apache.openjpa.persistence.PersistenceException: Schema 'USER' does not > exist {SELECT x FROM Employee x WHERE x.id = ?} [code=30000, state=42Y07] >
