Hi all,

Need some help in JPAQL in GAE. The JPAQL specs say that you can create
objects from a JPA query directly. e.g.

I wrote the following code


Query q = manager.createQuery("SELECT new com.test.Person(p.id, p.firstName,
p.lastName) from Person p");

*List* results = q.getResultList();

It threw the following exception.

org.datanucleus.store.appengine.query.DatastoreQuery$UnsupportedDatastoreOperatorException:
Problem with query <SELECT new com.test.Person(p.id, p.firstName,
p.lastName) from Person p>: App Engine datastore does not support operator
org.datanucleus.query.expression.CreatorExpression.

As per the JPA tutorial, constructor expressions are allowed.

Am I doing anything wrong here, or is appengine does not support it.

If the later is true, how do I solve this problem of selecting only
selective properties from an entity. Follow up question is what if there is
a one to many relationship between Person and Company, where person has a
lookup to Company and in the above query I want to get id of the company and
name of the company only and not other details like address, phone, etc.

Something similar in SQL, without the constructor expression would be

SELECT p.id, p.firstName, p.lastName, p.companyId, c.companyName from Person
p, Company c where p.companyId = c.id

OR in JPA QL

SELECT new Person(id, firstName, lastName, new Company(c.id, c.companyName)
from Person p, Company c where p.companyId = c.id

I am sure, the above expression is incorrect, but I want something to that
effect. Can I do this on GAE? This would help me design efficient queries
and still not take away OOness of JPA.

Any help is welcome.

Thanks.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.


Reply via email to