Getting error 'Cannot update object without any properties: selfUser'

Hello. I am developing on Android. Hope you can help

I am trying to save friendship relationship in separate class

I have class of users

package intellection.kz.wallswapp.Model;

import java.util.Date;

import io.realm.RealmObject;

/**

  • Created by bahakz on 3/30/16.
    */
    public class Users extends RealmObject {

    private String objectId;
    private Date created;
    private Date updated;
    private String phone;
    private String name;

    public String getObjectId() {
    return objectId;
    }

    public void setObjectId(String objectId) {
    this.objectId = objectId;
    }

    public Date getCreated() {
    return created;
    }

    public void setCreated(Date created) {
    this.created = created;
    }

    public Date getUpdated() {
    return updated;
    }

    public void setUpdated(Date updated) {
    this.updated = updated;
    }

    public String getPhone() {
    return phone;
    }

    public void setPhone(String phone) {
    this.phone = phone;
    }

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }
    }
    and
    Class for friend
    public class Friend extends RealmObject {

    private String objectId;
    private Users selfUser;
    private Users friendUser;
    private boolean inContacts;

    public String getObjectId() {
    return objectId;
    }

    public void setObjectId(String objectId) {
    this.objectId = objectId;
    }

    public Users getSelfUser() {
    return selfUser;
    }

    public void setSelfUser(Users selfUser) {
    this.selfUser = selfUser;
    }

    public Users getFriendUser() {
    return friendUser;
    }

    public void setFriendUser(Users friendUser) {
    this.friendUser = friendUser;
    }

    public boolean isInContacts() {
    return inContacts;
    }

    public void setInContacts(boolean inContacts) {
    this.inContacts = inContacts;
    }
    }
    When I try to save // new friend TODO: notify user
    Users friendUser = userResults.getData().get(0);
    Friend friend = new Friend();
    friend.setSelfUser(user);
    friend.setFriendUser(friendUser);
    friend.setInContacts(true);

Log.d(TAG, "saving self " + friend.getSelfUser().getObjectId() + " and friend " + friend.getFriendUser().getObjectId());
Friend savedFriend = Backendless.Persistence.save(friend);
I get the following error BackendlessException{ code: ‘1001’, message: ‘Cannot update object without any properties: selfUser’ }
May it is issue with me using RealmObject subclasses ? However, it does save user when sign up I checked that property ‘selfUser’ and ‘friendUser’ is not null.
Thank you.

Creating a custom class for the Users table is not a good idea, you should use the BackendlessUser class from our SDK. I realize that our BackendlessUser does not extend from RealmObject. Perhaps you could extract the properties from BackendlessUser and save them in realm.