Mayur Pardeshi Mayur Pardeshi - 3 months ago 28
Java Question

How to query using objectify in Google App Engine app

I have one entity called MemberInfo and another entity called PaymentInfo.

private Key<MemberInfo> memberInfo;
private double aCharges;
private double bCharges;
private double cCharges;

//And my query is as below

Query<PaymentInfo> query = OfyService.ofy().load().type(PaymentInfo.class);
Key<PaymentInfo> memberInfoKey = Key.create(PaymentInfo.class,membershipId);
query = query.filter("=", memberInfoKey);
return query.list();

Above is code that I have written but I am getting null result. I want result from PaymentInfo entity whose memberId is in Member entity

I want to query on PaymentInfo and get result of different payments paid by particular Member using memberId in MemberInfo in PaymentInfo. I have different fields like charges and one more field as
@Parent Key<MemberInfo>


I think you may need to add the name of the field that you are filtering on in your filter call, so query.filter("=", memberInfoKey) would become query.filter("memberInfo", memberInfoKey)

This is how I've managed to get it working before, and here are the docs with some more examples