2015-01-23 4 views
2

, 나는 다음과 같은 간단한 POJO를 만들었습니다 "종류"대신에 모음을 반환구글 엔드 포인트의 쿼리는 "ETAG"내 구글 엔드 포인트 구현에

Key<Channel> channelKey = Key.create(channelId); 
return ofy().load().type(Cartoon.class).ancestor(channelKey).list(); 

반환 (200) 결과 쿼리 다음과 같은 JSON

{ 
    "kind": "channel#resourcesItem", 
    "etag": "\"HvVI34INX8_n_JiuB-aYaj2l4Mg/ulgdYniw-Q\"" 
} 

복음 전도, ery time 새 Cartoon 객체를 만들 때,이 객체의 웹 안전 키는 조상 채널 객체의 String 목록에 추가됩니다.

{ 
"items": [ 
    { 
    "id": "180001", 
    "name": "Adventure Time", 
    "webSafeKey": "abcdefghij", 
    "kind": "channel#resourcesItem" 
    }, 
    { 
    "id": "190001", 
    "name": "The Amazing World of Gumball", 
    "webSafeKey": "aghzfm5vcW", 

    "kind": "channel#resourcesItem" 
    } 
], 
"kind": "channel#resources", 
"etag": "\"HvVI34INX8_n_JiuB-aYaj2l4Mg/ulgdYniw-Q\"" 
} 

어떤이 동작이 발생할 수 : 그래서 이상한 사실은이

return ofy().load().keys(cartoonKeys).values(); 

List<String>에서 List<Key<Cartoon>>를 작성하고 호출하는 경우이 방법은 예상 된 결과 일 것입니다 무슨 반환입니까?

답변

1

문제는 채널 POJO에 Satellite이라는 조상이 있으므로 채널 ID에서 Key<Channel> 개체를 다시 만들 수 없습니다. 따라서 쿼리는 을 완벽하게으로 처리하고 있습니다. 즉, 정보가있는 조상 키가 존재하지 않으므로 Cartoon 개체가 없습니다. Google Code repositorycom.googlecode.objectify.Key 구현을 보면

, 당신은 조상이 너무 조상이있는 경우,이 같은 키 다시해야한다는주의 사항 :

Key<Satellite> satelliteKey = Key.create(Satellite.class, satelliteId); 
Key<Channel> channelKey = Key.create(satelliteKey, Channel.class, channelId); 

을하지만 유효한 webSafeChannelKey 문자열 개체가, 당신은 할 수 전화 :

Key<Channel> channelKey = Key.create(webSafeChannelKey);