Android Studio 3.2,Java 1.7,Realm 4.1.0
这是我的pojo:
CREATE TRIGGER `insert_base_duplication_formula` BEFORE INSERT ON `bases`
FOR EACH ROW INSERT INTO base_formula(base_id,raw_material_id,percent,dispense,ignore_step,main_ingredient,cost_of_use,active_flag)
SELECT
NEW.base_id_pk,
bf.raw_material_id,
bf.percent,
bf.dispense,
bf.ignore_step,
bf.main_ingredient,
bf.cost_of_use,
0
FROM base_formula bf
WHERE NEW.base_duplicate IS NOT NULL
AND new.base_duplicate=bf.base_id
这是我如何更新public class ImageFormats extends RealmObject {
private ImageSource reference;
private ImageSource average;
}
public class ImageSource extends RealmObject {
private String url;
private int width;
private int height;
}
reference
很好用。
但是我不会更新 WHOLE 对象public void cascadeUpdate(Realm realm, ImageFormats that) {
if (!EqualsUtil.areEqual(this.average, that.average)) {
setAverage(that.average == null ? null : realm.copyToRealm(that.average));
}
}
,因为它可能仅更改一个属性,例如ImageSource
并且我尝试更新为已更改的仅Realm字段。 所以我试试这个:
url
但是我得到了编译错误:
public void cascadeUpdate(Realm realm, ImageSource that) {
if (!EqualsUtil.areEqual(this.url, that.url)) {
setUrl(that.url == null ? null : realm.copyToRealm(that.url)); // error here
}
}
那么,我如何才能将其更新为“仅Realm”字段?