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] -- View this message in context: http://openjpa.208410.n2.nabble.com/How-to-Specify-the-Schema-for-a-Named-Query-tp6085743p6085743.html Sent from the OpenJPA Users mailing list archive at Nabble.com.