尝试插入新对象时出现异常。
日志猫:
java.lang.IllegalStateException: Source entity has no ID (should have been put before)
at io.objectbox.relation.ToMany.internalCheckApplyToDbRequired(ToMany.java:599)
插入功能:
public static void setSyncData(long contactId, SyncerData syncData) {
final Box<SyncerData> box = getObjectBoxStore().boxFor(SyncerData.class);
SyncerData syncerData = box.query().equal(SyncerData_.id, contactId).build().findFirst();
if (syncerData == null) {
syncerData = new SyncerData();
syncerData.setPhoneOrIdKey(ContactData.generateId(Phone.EMPTY, contactId));
}
syncerData.setSyncerDetailsToMany(syncData.getSyncerDetailsToMany());
box.put(syncerData);
}
这是什么意思,在添加到对象之前,我不能将新对象 ToMany 列表放入?