我想知道是否有机会与 interhited 类建立关系。下面的例子不起作用,因为它抛出了关系“人”不存在的错误。如果我将 DatabaseTable 标记放在 Person 类上方,它也不起作用。Ormlite 是否支持与继承对象的关系?
public abstract class Person{
@DatabaseField(generatedId = true)
public int id;
@DatabaseField
public String name;
@DatabaseField(canBeNull = false, foreign = true)
private School school;
}
@DatabaseTable
public class Student extends Person{
@DatabaseField
public String class;
@DatabaseField
public String year;
}
@DatabaseTable
public class Teacher extends Person{
@DatabaseField
public String title;
}
@DatabaseTable
public class School {
@DatabaseField(generatedId = true)
public int id;
@ForeignCollectionField(eager = true)
ForeignCollection<Person> persons;
}