我有 3 个简单的 ORM 类(java + ormlite)
一个
@DatabaseTable
public class A extends BaseDaoEnabled {
A(){
bs = new ArrayList<B>();
}
@DatabaseField(generatedId=true)
int id;
@ForeignCollectionField(eager=true)
public Collection<B> bs;
}
乙
@DatabaseTable
public class B extends BaseDaoEnabled {
B(){}
@DatabaseField(generatedId=true)
int id;
@DatabaseField(foreign=true)
A a;
}
C
@DatabaseTable
public class C extends A{
@DatabaseField
int x;
}
A 一对多 B. C 扩展 A.
我可以写
B b = new B();
b.a = new C();
但是当我评估查询时出现异常:
java.sql.SQLException: Foreign collection class B for field 'bs' column-name does not contain a foreign field of class C
如何在扩展类的对象上设置链接(不需要每个子类的属性)?