【发布时间】:2017-12-21 09:47:54
【问题描述】:
我需要实现子章节并尝试以下方法:
@DatabaseTable(tableName = "chapters")
public class Chapter implements Serializable{
private static final long serialVersionUID = 3500051084584514827L;
@DatabaseField(generatedId = true)
private int _id;
@DatabaseField(canBeNull = false)
private String name;
@DatabaseField(canBeNull = false, foreign = true)
private Project project;
@ForeignCollectionField(eager = true, maxEagerForeignCollectionLevel = 2)
public ForeignCollection<Document> documents;
@ForeignCollectionField
public ForeignCollection<Chapter> subChapters;
public int getId() {
return _id;
}
public String getName() {
return name;
}
public Project getProject() {
return project;
}
Chapter() {
}
public Chapter(String name, Project project) {
this.name = name;
this.project = project;
}
}
但它给我抛出了一个异常:
无法创建数据库 java.sql.SQLException:外部集合类 ....models.db.Chapter for field 'subChapters' column-name 不包含类 ...models.db.Chapter 的外部字段
我在这里错过了什么?
【问题讨论】: