如何在 ORMLite Android 中实现一对多关系?
请找到示例
public class A {
private String name;
@DatabaseField (foreign = true, foreignAutoRefresh = true, columnName = "A")
private B b;
@DatabaseField(columnName = "author")
private String authorName;
}
public class B {
@DatabaseField(generatedId = true, columnName = "id")
private long id;
@DatabaseField(columnName = "name")
private String name;
@ForeignCollectionField
Collection<A> aees;
}
B有A的集合。我在打电话dao.create(b);
现在我创建 b 的 dao,因为 b 拥有所有数据。但是表 B 只用数据创建,A 从未创建。有人可以帮忙吗?