2017-04-12 39 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