【问题标题】:Query filtering with Objectify使用 Objectify 进行查询过滤
【发布时间】:2012-08-22 15:00:45
【问题描述】:

我有一个问题,我需要使用 Objectify 过滤查询结果。通常,存储实体上的 String @Key 字段如下所示:

  • uid:jamesm:points
  • uid:jsmith:points
  • uid:jax:points
  • uid:ken:points

现在我想为 @Key 字段做一个这样的查询过滤器:

uid:j*:points

我希望获得上面列出的前三 (3) 个实体。 Objectify 可以做到这一点吗?

【问题讨论】:

  • 您在寻找 LIKE 查询吗? code.google.com/p/objectify-appengine/wiki/… ,可能类似于这个 1 String start = "uid:j"; ... = ofy.query(MyEntity.class).filter("field >=", start).filter("field <", start + "\uFFFD:points");

标签: java google-app-engine objectify


【解决方案1】:

As described before,您可以这样做,但前提是您比较字符串的开头:uid:j*

ofy.query(EntityClass.class).filter("property >=", "uid:j")
                            .filter("property <", "uid:j" + "\ufffd");

【讨论】:

  • 你的意思是这行不通:ofy.query(MyEntity.class).filter("field >=", start).filter("field
猜你喜欢
  • 2012-09-28
  • 2013-01-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多