我在有关此问题的其他问题上看到了同样的错误。正如你所看到的,我似乎没有什么问题!除非我的眼睛欺骗了我。有什么帮助吗?
这是我的两个模型:
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
}
最佳答案
您忘记将 id = true
或 generatedId = true
添加到 @DatabaseField
注释中:
@DatabaseField(id = true, canBeNull = false, columnName = "id")
private int id;
关于java - ORMLite 外部字段类没有 id 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31300630/