DBFlow for android 没有好的文档,在阅读了有关如何在两个表之间建立简单关系的更多信息后,我无法做到这一点。
我有2张桌子:
MainCategories和SubCategories
在SubCategories我有channelId它存储在表中MainCategories,MainCategories有更多的数据SubCategories,(一对多)
现在我正在尝试实现这种关系:
我的代码不正确,与库文档类似
MainCategories:
@Table(database = AppDatabase.class)
public class ChannelContentCategories extends BaseModel {
@PrimaryKey(autoincrement = true)
private int id;
@Column
private int channelId;
@Column
private String title;
List<ChannelSubContentCategories> subContentCategories;
@OneToMany(methods = {OneToMany.Method.ALL})
public List<ChannelSubContentCategories> getMyChannelSubContentCategoriess() {
...
}
...
}
SubCategories:
@Table(database = AppDatabase.class)
public class ChannelSubContentCategories extends BaseModel {
@PrimaryKey(autoincrement = true)
private int id;
@Column
private int categoryId;
@Column
private int parentId;
@Column
private String title;
...
}
我怎样才能channelId在ChannelContentCategories桌子和parentId桌子之间建立简单的关系ChannelSubContentCategories?
提前致谢