父亲
@Data
@Table(name = "SponsorServer")
public class SponsorServer extends Model {
@SerializedName("timestamp")
@Column(name = "Timestamp")
private String timestamp;
@SerializedName("sponsorsList")
@Column(name = "SponsorLists", onUpdate = Column.ForeignKeyAction.CASCADE, onDelete = Column.ForeignKeyAction.CASCADE)
public List<SponsorList> sponsorLists;
}
孩子
@Data
@Table(name = "SponsorList")
public class SponsorList extends Model {
@SerializedName("id")
@Column(name = "SponsorListID", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
private int sponsorListID;
@SerializedName("order")
@Column(name = "SponsorListOrder")
private int order;
@SerializedName("name")
@Column(name = "Name")
private String name;
}
另一个班级
ActiveAndroid.beginTransaction();
try {
for (SponsorList sponsorList : sponsorServer.getSponsorLists()) {
for (Sponsor sponsor : sponsorList.getSponsors()) {
sponsor.save();
}
sponsorList.save();
}
sponsorServer.save();
ActiveAndroid.setTransactionSuccessful();
} finally {
ActiveAndroid.endTransaction();
SponsorServer sponsorServer1 = new Select().all().from(SponsorServer.class).executeSingle();
Log.d("", "-------- sponsorServer1 = " + sponsorServer1);
}
它的回归
赞助商服务器1 =赞助商服务器(时间戳=1276605030,赞助商列表=空)
如何将孩子保存在父亲对象中?
关系如何在 activeandroid 上工作?
我不明白
https://github.com/pardom/ActiveAndroid/wiki/Creating-your-database-model
tks