【发布时间】:2016-04-01 08:03:21
【问题描述】:
我是 Google Appengine 的新手。在我的应用程序中,数据存储实体存储 org.joda.time.DateTime 对象。我想查询数据存储以返回 2 个特定日期时间范围内的所有实体。我的代码是:
@Entity
@Cache
@Index
public class Sample {
@Id
Long id; // autogen
private DateTime dateTime;
private int activeCount;
private int inactiveCount;
}
我想要一个类似的查询 -
Iterable<Sample> sampleIterable = ofy().load().type(Sample.class)
.filter("dateTime <", DateTime.now())
.filter("dateTime >", DateTime.now().minusDays(1))
.iterable();
是否可以像这样查询 DateTime ?在 objectify 中查询 DateTime 的正确方法是什么?很抱歉没有说清楚。
【问题讨论】:
-
您是否在您的 objectify 服务/工厂注册了 joda 日期时间翻译器?如果是这样,这应该只是工作,假设存在正确的索引(在这种情况下,'dateTime'字段用@Index标记)
标签: java google-app-engine datetime objectify