ORMLite外部字段类没有id字段

时间:2015-07-08 18:20:51

标签: 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
}

1 个答案:

答案 0 :(得分:6)

您忘记将id = truegeneratedId = true添加到@DatabaseField注释中:

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