事情是这样的 :-) 我们有两个类,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;