I have a list of articles.
Those articles are inserted by using realm.copyToRealmOrUpdate();
which works perfectly fine.
Now each article has an autho
Are you using GSON? If so, did you follow the example as outlined in http://realm.io/docs/java/0.80.0/#gson?
Christian from Realm here. You keep manipulating the standalone objects you just copied to Realm, which won't work as they are still standalone objects and not "proper" Realm objects. You can read more here: http://realm.io/docs/java/0.80.0/#creating-objects and in the JavaDoc http://realm.io/docs/java/0.80.0/api/io/realm/Realm.html#copyToRealm-E-
So if you change you code to something like the below, it should work:
realm.executeTransaction(new Realm.Transaction() {
@Override
public void execute(Realm realm) {
List<Article> realmArticles = realm.copyToRealmOrUpdate(articles.data);
for(Article article : realmArticles) {
Author author = realm.where(Author.class).equalTo("id", article.getSerializedAuthor()).findFirst();
article.setAuthor(author);
for (Image image : article.getSerializedImages().data) {
article.getImages().add(image);
}
}
}
});