我有两个简单的模型,我正在尝试在它们之间创建简单的 OneToMany,就我是使用这个库的新手而言,我不能使用库文档,我的主要模型是:
@Table(database = AppDatabase.class)
public class ModelChannelPosts extends BaseModel {
@PrimaryKey
private int id;
@Column
private String channelId;
@Column
private List<ModelVideos> channel_video_containers;
@Column
private String createdAt;
@Column
private String updatedAt;
public ModelChannelPosts() {
}
@OneToMany(methods = {OneToMany.Method.ALL}, variableName = "channel_video_containers")
public List<ModelVideos> getVideos() {
if (channel_video_containers == null || channel_video_containers.isEmpty()) {
channel_video_containers = new Select()
.from(ModelVideos.class)
.where(ModelVideos_Table.channelId.eq(id))
.queryList();
}
return channel_video_containers;
}
...
}
那有很多ModelVideos
,然后ModelVideos
属于ModelChannelPosts
:
@Table(database = AppDatabase.class)
public class ModelVideos extends BaseModel {
@PrimaryKey
private int id;
@Column
private String fileName;
@Column
private String videoLength;
@Column
private int channelId;
public ModelVideos() {
}
...
}
在ModelChannelPosts_Table
文件model.channel_video_containers
中是未知的,我得到这个错误:
Error:(168, 48) error: <identifier> expected
我该如何OneToMany
为他们实施?(在channel_video_containers
onModelChannelPosts
和channelId
on之间建立关系ModelVideos
?