Android 多个ToMany用于1个表greenDAO
我有两个这样的型号:Android 多个ToMany用于1个表greenDAO,android,sqlite,greendao,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 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;
}
@实体
公共课堂用书{
@身份证
长id;
字符串名;
@ToMany(referencedJoinProperty=“bookId”)
列出第1章;
@ToMany(referencedJoinProperty=“bookId”)
列出第2章;
}
@实体
公共课章节{
@身份证
长id;
字符串名;
int型;
长书号;
@ToOne(joinProperty=“bookId”)
书籍;
}
第1章和第2章有两种类型,目前,当我得到第1章时,greenDAO返回所有的第1章和第2章,我怎么能在课堂上只得到第1章或第2章 尝试执行此查询
Select from Chapter where type = [1 or 2]
我知道我可以编写这样的查询,但我想通过greenDAO生成的代码检索预期结果。有没有办法做到这一点?