Reputation: 41
Question is related to Google app engine Java.
I have two objects Employee, Address. Each employee has a list of addresses init and also has a String status of current/retired/left/fired.
Now I want to get a list of all my current employees who are Houston based.
Class Employee {
@Persistent(mappedBy="employee")
List<Address> addresses;
String status;
}
Class Address {
@Persistent
private Employee employee;
String address1;
String city;
String zip;
}
On my db class how do tell my query to do what i need.
Query query = pm.newQuery(Employee.class, whereClause.toString());
List<Employee> empList = (List<Employee>) query.executeWithArray(paramValues.toArray());
When I set my status parameter to current, it will give me a list of current employees, how do i add the condition of "Houston" into my query so that I dont have to do the filter by myself.
I feel that I am missing something. Appreciate you help.
Upvotes: 2
Views: 311
Reputation: 101139
This would require a join, and so isn't possible in a query on App Engine. Your best option would be to query on all address entities from Houston, then fetch their Employee records and filter (in memory) by status.
Upvotes: 1