我有一个模型
public class Response extends RealmObject {
@PrimaryKey
private String _id;
private RealmList<TaskResponse> task_responses;
private AssignmentRecord assignmentRecord;
private ResponseStatistic responseStats;
}
现在,我正在尝试将 task_responses realmlist 保存在 Response 中,但未能成功,以下是相关代码:
mRealm.beginTransaction();
response.setTaskResponses(taskResponses);
response.setAssignmentRecord(assignmentRecord);
response.setResponseStats(responseStatistic);
mRealm.commitTransaction();
当我在此行之前放置调试器时
response.setTaskResponses(taskResponses);
taskResponses 的大小为 5,但执行后它变为空并且领域存储一个空列表。
任务响应模型:
public class TaskResponse extends RealmObject {
@PrimaryKey
private String _id;
private String taskId;
private Boolean answered;
private String answer;
private TaskStatistic taskStat;
}