Reputation: 563
I'm trying to have my GAE app pull some records from the Datastore but keep getting this:
javax.persistence.PersistenceException: Class PersistableItem for query has not been resolved. Check the query and any imports specification
It's from the method here:
public List<PersistableItem> listItems() {
EntityManager em = EMFService.get().createEntityManager();
// Read the existing entries
Query q = em.createQuery("select * from PersistableItem");
List<PersistableItem> items = q.getResultList();
return items;
}
From what I've read this is about importing my PersistableItem class but I'm confused as I already do that in the .java code files.
Upvotes: 0
Views: 1396
Reputation: 5198
I had the same error even with the right JPQL query and solved adding the class declarations in the persistence.xml
<persistence-unit name="appengine-transactions-optional">
<provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
<class>it.gustaff.data.Place</class>
<class>it.gustaff.data.Menu</class>
<properties>
<property name="datanucleus.NontransactionalRead" value="true"/>
<property name="datanucleus.NontransactionalWrite" value="true"/>
<property name="datanucleus.ConnectionURL" value="appengine"/>
</properties>
</persistence-unit>
Upvotes: 2
Reputation: 692121
The error message is strange, so this might not be your only error, but your query is wrong. select * is SQL, not JPQL. The correct query is
select p from PersistableItem p
Upvotes: 2
Reputation: 15229
Is the class "PersistableItem" present in your project (or in a dependency of your project). Does it have the @Entity
class level annotation. Does it implement Serializable. In your JPQL try using the fully qualified name of the class ("select * from package1.package2.PersistableItem")
Upvotes: 2