2009-07-17 6 views
0

나는 내 태그 엔티티에 키 세트를 포함하는 Course 엔티티를 가지고 있습니다. 특정 태그가있는 코스 목록을 얻기 위해 검색어를 만드는 방법은 무엇입니까? 예를 들어, java로 태그 된 모든 코스를 찾고 싶습니다. 나는 이것이 가능하다고 생각하지 않습니다Google 데이터 저장소 쿼리 세트

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") 
public class Course{ 

@PrimaryKey 
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
private Key key; 

@Persistent private Set<Key>  tags; 
//etc 
} 

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true") 
public class Tag{ 

    @PrimaryKey 
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
    private Key key; 

    @Persistent private String tagText; 
} 
+1

google 데이터 스토어를 추가 할 때 조인이 없기 때문에 데이터를 비정규 화하는 것이 좋습니다. 즉, 태그 유형을 통해 퍼널링하지 않고 태그를 설정하십시오. – bdonlan

+0

그건 이상적이지만, 그냥 문자열보다 내 태그 개체에 더 있습니다. – KevMo

답변

3
Tag tag = getTagFromString("java"); 
Key tagKey = tag.getKey(); // i will assume you have a getKey() method 

PersistenceManger pm = PMF.get().getPersistenceManager(); 
Query q = pm.newQuery(Course.class); 
q.setFilter("tags == :tagParam"); 

List<Course> coursesTaggedWithJava = (List<Course>) q.execute(tagKey); 
0

: 여기

내 엔티티입니다. Google 데이터 저장소에서는 가입 쿼리를 사용할 수 없습니다. 하지만 나는 틀릴 수도 있습니다.

Herehere은 GQL에 대한 자세한 정보를 볼 수있는 웹 사이트입니다.