2012-05-28 2 views
0

여기에 우리는 두 개의 클래스, AppointmentHairdresser, 같은 하나의 조상 (topParent 정적 최종 키)를 가진 모두가 :-) 건입니다.
객관화 구글 DataSore 쿼리

@Parent 
    public Key parent; 
    public Key hairdresserKey;` 


을하지만 우리는 약속을 필터링 할 때,이 결과와 함께 제공되지 않습니다 다음 Appointment이 같은 Hairdresser가 포함되어 있습니다. hairdresserKey == null에있는 부모님, 단서 일 수도 있지만 지금은 고생하고 있습니다.

누군가이 쿼리에 어떤 문제가 있는지 알려주세요.

고맙습니다. 이

@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; 
+0

{ancestor, hairdresserKey, timeSlot, LENGTH} * 및 * 모든 속성 값에 대해 단일 속성 색인을 모두 생성 했습니까? – stickfigure

답변

0

구현 :

이 거의 확실하다

 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(); 

는이 약속을 설정하는 방법입니다, 좀 더 clearify하려면 색인 문제. 작업에 해당 쿼리 위해서는, 두 개의 인덱스를 정의해야합니다

객관화 3.x의에서 referenceKeyToC 에 다중 속성 인덱스 {조상, referenceKeyToC} 에 단일 속성 인덱스를, 속성은 단일 속성 인덱스가 기본적으로 @Unindexed를 클래스 B에 추가 한 경우 referenceKeyToC에 @Indexed를 넣어야합니다. 다중 등록 정보 색인은 datastore-indexes.xml에 정의되어 있습니다. dev 모드에서이 쿼리를 실행하면 환경에서 필요한 xml 스 니펫을 제공해야합니다.

그건 속임수 였어! 올바른 방향을 가리켜 주셔서 감사합니다!