views:

148

answers:

1

Hello,

I'm currently developing in GAE and I have to query like this using JDO:

SELECT table1.column1, table2.column2 FROM table1, table2 WHERE table1.column1 = table2.column1;

I tried this one but it won't work:

    String query = "select from "+Assessment.class.getName()+ "a, "+ 
                        Project.class.getName()+" p where a.projectId == p.id && p.owner=='"+owner+"'";

Is this valid or this really isn't supported yet? If this is valid, why is it not working then? If it isn't, what should I do to make this work?

Thank you!

A: 

Perhaps familiarise yourself with JDOQL. You cannot have multiple "candidate" types. A simple JDOQL query cannot return more than 1 candidate type, obviously, since it makes no sense. You expect objects of type Assessment back, so that is the candidate. If Assessment and Project are related then you use the relation fields within the where clause, and if not related then you use a variable (also in the docs).

If you want to just return a field of class 1 and a field of class 2 then specify that in the result clause. SELECT this.field1, this.project.field2 FROM mydomain.Assessment WHERE this.project.owner = "value"

DataNucleus