【发布时间】:2012-05-28 10:19:15
【问题描述】:
事情是这样的 :-)
我们有两个类,Appointment 和 Hairdresser,它们都具有相同的一个祖先(静态最终密钥:topParent)代表 HairSalon 密钥。 Appointment 包含 Hairdresser,如下所示:
@Parent
public Key parent;
public Key hairdresserKey;`
但是当我们试图过滤掉约会时,它并没有得出结果。 hairdresserKey == null 中的父级,这可能是一个线索,但我们现在有点卡住了。
那么有人可以告诉我们这个查询有什么问题吗?
非常感谢!
appointment.hairdresserKey = new Key<Hairdresser>(topParent, Hairdresser.class, appointment.hairdresser.id);
appointment.parent = topParent;
Key<Hairdresser> queryKey = new Key<Hairdresser>(topParent, Hairdresser.class, appointment.hairdresser.id);
Objectify ofyTransaction = ObjectifyService.beginTransaction();
try {
List<Key<Appointment>> previousTimeSlotOneHour = ofyTransaction.query(Appointment.class)
.ancestor(topParent)
.filter("hairdresserKey", appointment.hairdresserKey)
.filter("timeSlot", appointment.timeSlot.getPreviousTimeSlot())
.filter("LENGTH", 1.0d).listKeys();
为了更清楚一些,这是 Appointment 的设置方式:
@Unindexed
公共类约会实现可序列化{
@Id
public Long id;
@Indexed
public TimeSlot timeSlot;
@Transient
public WorkDay workDay;
@Transient
public Customer customer;
public Key customerKey;
public int END_TIME_HOUR;
public int END_TIME_MINUTES;
@Indexed
public TREATMENT treatment = TREATMENT.TREATMENT_CUT;
public int revisionNumber = -1;
/* QUERY Fields */
@Indexed
private String stringDate;
private double LENGTH;
@Parent
public Key parent;
private Date date;
@Transient
public Hairdresser hairdresser;
public Key hairdresserKey;
【问题讨论】:
-
您是否为所有这些字段创建了跨 {ancestor, hairdresserKey, timeSlot, LENGTH} 和 单属性索引的多属性索引?