开发者

Why error "Joins are only supported when all filters are 'equals' filters."

开发者 https://www.devze.com 2023-03-22 02:46 出处:网络
I am not sure what am I doning wrong here? It complains \"Joins are only supported when all fi开发者_运维技巧lters are \'equals\' filters.\" when the query is executed. How can I get around that?

I am not sure what am I doning wrong here? It complains "Joins are only supported when all fi开发者_运维技巧lters are 'equals' filters." when the query is executed. How can I get around that?

Query query = pm.newQuery(ItemInfo.class);

if (lastSyncDate != null) {
    query.declareVariables("DeviceInfo deviceInfo");
    query.setFilter("this.toDevices.contains(deviceInfo) && " +
    "deviceInfo.phoneNumber == numberParam && createdDate > lastSyncDateParam");
    query.declareParameters("String numberParam, java.util.Date lastSyncDateParam");
    map.put("lastSyncDateParam", lastSyncDate);
} else {
    query.declareVariables("DeviceInfo deviceInfo");
    query.setFilter("this.toDevices.contains(deviceInfo) && deviceInfo.phoneNumber == numberParam");

    query.declareParameters("String numberParam");
}
map.put("numberParam", "123456");
query.setOrdering("createdDate desc");

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class ItemInfo {

   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
   private Long id;

   @Persistent
   private String number;

   @Persistent
   private List<DeviceInfo> toDevices;
}


App Engine's datastore isn't relational, and doesn't support joins, which you're doing implicitly by using a field on a referenced model. Instead, you should fetch the entity or entities with the given phone number, and use the keys of those entities to filter your result dataset, eliminating the implied join.

0

精彩评论

暂无评论...
验证码 换一张
取 消