ORMLite外部字段类没有id字段

rem*_*dy. 0 java android ormlite

我在其他关于这个问题的问题上看到了同样的错误.正如你所看到的,似乎我没有任何错误!除非我的眼睛一直在欺骗我.有帮助吗?

这是我的两个模型:

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
}
Run Code Online (Sandbox Code Playgroud)

Ken*_*ndt 7

你忘了添加id = truegeneratedId = true@DatabaseField注解:

@DatabaseField(id = true, canBeNull = false, columnName = "id")
private int id;
Run Code Online (Sandbox Code Playgroud)