openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kojak <>
Subject How to Specify the Schema for a Named Query
Date Thu, 03 Mar 2011 17:54:17 GMT

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:

Here is my first test with a native query...

  @NamedNativeQuery(name = "getByID",  
  		resultClass = com.mycompany.Employee.class, 
		query = "SELECT x FROM Employee x WHERE = ?1")
  @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 = ?} [code=30000, state=42Y07]

View this message in context:
Sent from the OpenJPA Users mailing list archive at

View raw message