多个ToMany为1表格greenDA

时间:2017-04-12 08:46:30

标签: android sqlite 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种类型的章节类型1和2,目前,当我得到章节1时,greenDAO返回所有类型1和2,如何在类Book中只获得type1或2?

1 个答案:

答案 0 :(得分:0)

尝试执行此查询

Select from Chapter where type = [1 or 2]