当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Abstract Nesting class in ormlite

问题描述:

I have a project which contains three type of nested object, Location, category and value list. Each object is a tree which contains a parent field and children field. So I want to create an abstract class as a base class and i'm using ormlite to persist the records.

my Abstract class looks like this:

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

}

But when i run the app i get this error from ormlite:

Foreign collection SelectionValue for field 'children' column-name does not contain a

foreign field of class Location.

Is there a solution to this?

网友答案:

Your dataType for your children is wrong. According to the ORMLite manual: http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_2.html#Foreign-Collection Your class should look like this:

@ForeignCollectionField
private ForeignCollection<SelectionValue> children;
分享给朋友:
您可能感兴趣的文章:
随机阅读: