我在其他有关此问题的问题上看到过相同的错误。正如你所看到的,似乎我没有任何错误!除非我的眼睛一直在欺骗我。有什么帮助吗?
以下是我的两个模型:
public class Outer {
@DatabaseField(id = true, canBeNull = false, columnName = "id")
private int id;
@DatabaseField
private long parentOuterId;
@ForeignCollectionField(eager = false)
private ForeignCollection<Item> items;
//getters and setters
}
public class Item {
@DatabaseField(canBeNull = false, columnName = "id")
private int id;
@DatabaseField(canBeNull = false, foreign = true, foreignAutoRefresh = true)
private Outer out;
//getters and setters
}
答案 0 :(得分:6)
您忘记将id = true
或generatedId = true
添加到@DatabaseField
注释中:
@DatabaseField(id = true, canBeNull = false, columnName = "id")
private int id;