Realm-java: IllegalArgumentException: 'value' is not a valid managed object

Created on 11 Jul 2016  路  3Comments  路  Source: realm/realm-java

Hello. Would you be so kind to help me update attached model. The example of the code is attached below. Again and again I see the one mistake and nothing can avoid it including suggested solution

public void setMessage(final Message message) {

    mRealm.beginTransaction();
    mRealm.copyToRealmOrUpdate(message);
    mRealm.commitTransaction();


    mRealm.beginTransaction();
    Chat chat = getChat(message.getApplicant());
    chat.setLast_message(message);
    mRealm.copyToRealmOrUpdate(chat);
    mRealm.commitTransaction();

}
T-Help

Most helpful comment

Can't you do that in ONE transaction?

Anyways, the issue is that your message remains unmanaged because you didn't do message = mRealm.copyToRealmOrUpdate(message).

All 3 comments

Can't you do that in ONE transaction?

Anyways, the issue is that your message remains unmanaged because you didn't do message = mRealm.copyToRealmOrUpdate(message).

Thx a lot!

@Zhuinden Thanks a again!

Was this page helpful?
0 / 5 - 0 ratings