外部字段 class 没有 id 字段

Foreign field class does not have id field

我在下面的实体中遇到错误(可能是因为一对多的关系),但我不知道如何解决这个问题。

课程:

@ForeignCollectionField(eager = true)
Collection<Grade> grades;

@DatabaseField(columnName = "ID", canBeNull = false)
private long id;

@DatabaseField(columnName = "LABEL", canBeNull = false)
private String label;

@DatabaseField(columnName = "COEFFICIENT", canBeNull = false, defaultValue = "1")
private float coefficient;

年级:

@DatabaseField(columnName = "ID_COURSE", canBeNull = false, foreign = true, foreignAutoRefresh = true)
Course course;

@DatabaseField(columnName = "ID", canBeNull = false)
private long id;

@DatabaseField(columnName = "DATE", canBeNull = false)
private Date date;

@DatabaseField(columnName = "GRADE", canBeNull = false, defaultValue = "1")
private float grade;

启动应用程序并尝试从数据库中获取数据时:

Foreign field class Course does not have id field

课程 class 必须有 id 字段

@DatabaseField(generatedId = true, columnName = "ID")
Long id;

或通过以下方式将您现有的字段 ID 设为 id:

@DatabaseField(id = true, columnName = "ID", canBeNull = false)
private long id;