Google app engine 在Objectify中选择具有贴图属性的不同投影
今天我遇到了一个很糟糕的问题 首先,这里是我的实体模型:Google app engine 在Objectify中选择具有贴图属性的不同投影,google-app-engine,objectify,google-cloud-datastore,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 pai
@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
}
我想询问数据存储“select data.key2 from Lead
?”,他应该用以下结果回答:[value2A,value2B,value2C]
因此,我对数据存储的ProjectionQuery表现出了兴趣,但在尝试使用objectify(通过.project()服务)实现它几次失败后,我开始考虑它的局限性
同一属性不能投影多次。
我现在想知道这是否就是它糟糕的原因
过去有没有人做到这一点
非常感谢如果在GAE控制台中使用
从Lead中选择data.key2是否会产生预期的结果?它与此查询完全一致:从Lead中选择DISTINCT`data.key2`
!!!谢谢你的提示!自从objectify 5.0.3:of y().load().type(Lead.class).project(“data.key2”).now()
以来,@PeterKnegoProjection查询应该是可用的,这真的很有帮助。。。但是我通过DatastoreService和ProjectionQuery成功地解决了这个问题,我放弃了Objectify来进行那个查询。我正在认真考虑报告这个问题;)请这样做-错误不会得到修复,如果他们去报告。
leadA.data = [key1 -> value1A, key2 -> value2A, key3 -> value3A]
leadB.data = [key1 -> value1B, key2 -> value2B, key3 -> value3B]
leadC.data = [key1 -> value1C, key2 -> value2C, key3 -> value3C]