ORMLite 外域 class 没有 id 域

ORMLite Foreign field class does not have id field

我在有关此问题的其他问题上看到了完全相同的错误。如您所见,我似乎没有任何问题!除非我的眼睛一直在欺骗我。有帮助吗?

这是我的两个模型:

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
}

您忘记在 @DatabaseField 注释中添加 id = truegeneratedId = true

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