【问题标题】:How to filter in datastore using objectify for a Date property ?如何使用 objectify 过滤数据存储区的 Date 属性?
【发布时间】:2015-05-18 20:21:36
【问题描述】:

如何使用 objectify 过滤数据存储区的 Date 属性? 我有一个看起来像 pojo 类下面的实体。在这个 timeStamp 是一个保存日期值的属性。

public class TravelEntry {
    private String deviceId;
    private String pushedGeoData;
    private String location;
    private Date timeStamp;

    public TravelEntry(){
        setTimeStamp(this.timeStamp);
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }


    public String getPushedGeoData() {
        return pushedGeoData;
    }

    public void setPushedGeoData(String pushedGeoData) {
        this.pushedGeoData = pushedGeoData;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        if(timeStamp==null){
            this.timeStamp = new Date();
        }else{
            this.timeStamp = timeStamp;
        }

    }


}

如何使用 Objectify 查询或过滤 Date 属性? 我想检索所有具有特定日期和时间的实体。

【问题讨论】:

    标签: google-app-engine google-cloud-datastore objectify


    【解决方案1】:

    文档中都有详细说明:

    https://code.google.com/p/objectify-appengine/wiki/Queries

    @Index 字段,然后按所需的日期值过滤。

    【讨论】:

      猜你喜欢
      • 2012-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多