【问题标题】:Multiple ToMany for 1 table greenDAO1张表greenDAO的多个ToMany
【发布时间】:2017-04-12 16:50:29
【问题描述】:

我有 2 个这样的模型:

@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,目前,当我得到champions1时,greenDAO返回所有type1和2,我怎样才能在类Book中只得到type1或2?

【问题讨论】:

    标签: android sqlite greendao


    【解决方案1】:

    尝试执行这个查询

    Select from Chapter where type = [1 or 2]
    

    【讨论】:

    • 我知道我可以编写这样的查询,但我想通过 greenDAO 生成的代码检索预期结果。有没有办法做到这一点?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 2013-10-30
    • 1970-01-01
    相关资源
    最近更新 更多