我在Realm对象中定义了两个表(Dog& Person),需要使用1:n关系。
我的人员课程是:
public class Person extends RealmObject {
@PrimaryKey
private int id;
private int age;
private Dog dog;
/** Getters & setters **/
}
我的狗课是:
public class Dog extends RealmObject {
@PrimaryKey
public int id;
public String name;
/** Getters & setters **/
}
当表格“Dogs”包含从互联网加载的数据时。我需要在我的Person表中添加dog id作为关系,当保存对象Person时。如果保存到“人员”表dogId,比我不加入数据。我需要来自Person的选择数据包括狗名。
可以作为关系吗?或者我使用另一个领域查询,我将在哪里搜索id?
感谢您的回复。