2017-04-12 43 views
0

我有2個型號是這樣的:多個一對多1個表greenDAO

@Entity 
public class Book { 

    @Id 
    Long _id; 

    String name; 

    @ToMany(referencedJoinProperty = "bookId") 
    List<Chapter> chapters1; 

    @ToMany(referencedJoinProperty = "bookId") 
    List<Chapter> chapters2; 
} 


@Entity 
public class Chapter { 

    @Id 
    Long _id; 

    String name; 
    int type; 
    long bookId; 
    @ToOne(joinProperty = "bookId") 
    Book book; 
} 

有2型章type1和2,目前,當我得到chapters1,greenDAO返回所有type1和2,我怎麼能Book類中只有type1或2?

回答

0

嘗試執行此查詢

Select from Chapter where type = [1 or 2] 
+0

我知道,我可以寫一個這樣的查詢,但我想要檢索預期結果通過greenDAO生成的代碼。有沒有辦法做到這一點? – maphongba008