我有一个项目,其中包含三种类型的嵌套对象,位置,类别和值列表。每个对象都是一个树,其中包含一个父字段和一个子字段。所以我想创建一个抽象类作为基类,并使用ormlite来持久化记录。
我的Abstract类如下所示:
public abstract class SelectionValue {
    @DatabaseField(generatedId = true, columnName = "_id")
    private long id;
    @DatabaseField
    private String label;
    @DatabaseField
    private int sort;
    @DatabaseField
    private long valueId;
    @ForeignCollectionField
    private Collection<SelectionValue> children;
    @DatabaseField (foreign = true, foreignAutoRefresh = true)
    private SelectionValue parent;
    // setters and gettings 
}但是当我运行这个应用程序时,我从ormlite得到了这个错误:
Foreign collection SelectionValue for field 'children' column-name does not contain a
    foreign field of class Location.对此有解决方案吗?
发布于 2015-08-04 00:12:12
您孩子的dataType是错误的。根据ORMLite手册:http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_2.html#Foreign-Collection你的类应该是这样的:
@ForeignCollectionField
private ForeignCollection<SelectionValue> children;https://stackoverflow.com/questions/31578852
复制相似问题