开发者

Querying for @Embedded map in objectify for GAE

P开发者_如何学编程lease consider following sample

@Entity
public class Abc {
    @Id
    private Long id;

    @Unindexed
    private String name;

    @Embedded
    private Map<String, Xyz> objs;
}

public class Xyz {
    private String objName;
    private String objStatus;
}

Now I want the object of Abc such that objs.get("someKey").getObjName().equals("someName") is true.

How do I make this query in Objectify? Also, if I store 'objs' as list instead of map, can I query for an object of Abc such that one of the list values have objName as 'someName'? Need help in this. Thanks


You should be able to query like this:

Objectify ofy = factory.begin
ofy.query(Abc.class).filter("objs.someKey.objName=", "someName")

The map keys are simple folded into the map of properties of the entity, using a dot as the separator and the name of the map field ("objs") as a prefix to avoid collisions.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜