在Objectify中选择带有Map属性的Distinct Projection

时间:2015-01-19 18:21:27

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

今天我遇到了一个非常糟糕的问题。

首先,这是我的实体模型:

@Entity
public class Lead {
    @Id
    private String url;

    @Index
    private Date dateCreated;

    @Index
    private Date lastDateModified;

    //This might hold hundreds of key-value couples
    //it's very painful to fetch the whole entity when we are only interested in one "column", knowing that there are more that 100.000 entities
    @Index
    private Map<String, Object> data = new HashMap<>(); 

    public Lead(String url) {
        this.url = url;
        this.dateCreated = new Date();
    }

    //getters and setters

}

如果我有多个&#34;领先&#34;具有以下数据映射的实体:

leadA.data = [key1 -> value1A, key2 -> value2A, key3 -> value3A]
leadB.data = [key1 -> value1B, key2 -> value2B, key3 -> value3B]
leadC.data = [key1 -> value1C, key2 -> value2C, key3 -> value3C]

我想问一下数据存储&#34; select data.key2 from Lead?&#34;他应该通过以下结果回答:[value2A, value2B, value2C]

所以我对Datastore的ProjectionQuery表示了兴趣,但是在几次尝试用objectify(通过.project()服务)实现它之后,我开始考虑局限性

  

同一财产不能多次投射。   我现在想知道这是不是很糟糕?

过去有人能做到这一点吗?

非常感谢

0 个答案:

没有答案