如何使用objectify创建的实体过滤GQL中的查询?

时间:2013-12-04 06:02:44

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

我在数据存储区查看器中有以下名为MACObs的表:

ID/Name         accessPoint             mac                     obs
id=42310053     xx:xx:xx:xx:xx:xx       yy:yy:yy:yy:yy:yy       302 bytes, SHA-1 = 031688dc48d2e71bc80b1c16016cbb108c5af3e7

所以现在我认为我可以这样做一个GQL查询:

SELECT * FROM MACObs WHERE accessPoint = 'xx:xx:xx:xx:xx:xx'

但是当我运行此查询时,我只得到这个答案:

No results in Empty namespace.

也许重要的是说我在后端使用客观化创建实体。

1 个答案:

答案 0 :(得分:0)

行。以下是Objectify的文档“Objectify默认情况下不会对属性进行索引。您必须使用@Index注释显式定义单属性索引。”

请尝试以下操作:在您的accessPoint属性中添加@Index注释。

所以你的定义将成为:

@Entity 
public class MACObs { 
  @Id private Long id; 
  private String mac; 
  @Index private String accessPoint; 
  @Serialize private ArrayList<Long[]> obs; 
  ...
  getter/setter methods
  ...
}