Can't update already exists object related with BackendlessUser

Can’t update already exists object NDevice related with BackendlessUser.
field android_id is unique.
I have next error:
update fault: BackendlessFault{ code: ‘1155’, message: ‘Duplicate entry’ }
Application class:

Backendless.Data.mapTableToClass("NDevice", NDevice.class);
Backendless.initApp(this, Consts.BACKENDLESS_APP_ID, Consts.BACKENDLESS_SECRET_KEY, "v1");
public class NDevice implements Serializable {

    public String android_id;
    public String gcm_token;
    public String model;
    public String digit_id;

    private Boolean notEmpty;
    private String objectId;
    private java.util.Date created;
    private java.util.Date updated;

    public String getAndroid_id() {
        return android_id;

    public void setAndroid_id(String android_id) {
        this.android_id = android_id;

    public String getGcm_token() {
        return gcm_token;

    public void setGcm_token(String gcm_token) {
        this.gcm_token = gcm_token;

    public String getModel() {
        return model;

    public void setModel(String model) {
        this.model = model;

    public String getDigit_id() {
        return digit_id;

    public void setDigit_id(String digit_id) {
        this.digit_id = digit_id;

    public Boolean getNotEmpty() {
        return notEmpty;

    public void setNotEmpty(Boolean notEmpty) {
        this.notEmpty = notEmpty;

    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;
private static void updateFields(BackendlessUser user) {
 NDevice device = NUser.i().device();
 user.setProperty("device", device);
private void updateUser(BackendlessUser user) {

 if (user != null) {


 Backendless.UserService.update(user, new AsyncCallback<BackendlessUser>() {
 public void handleResponse(BackendlessUser user) {

 public void handleFault(BackendlessFault fault) {
 NoteMessage.showAlert("update fault", fault.toString());


Hi Oleg,

Please check if adding “String objectId” property with getters and setters to your model class would help.

Updated NDevice object with all fields, getters and setters.

Still not working.
The same error:
update fault: BackendlessFault{ code: ‘1155’, message: ‘Duplicate entry’ }

Does it work if you remove the unique constraint (as a test) ?

If I leave unique field, it works, but it creates new object.
I need the same object and update it when it needs.

If the object you persist already contains a valid objectId, it should update the existing object. We will verify the behavior if there is a “unique” constraint present.

Yes, it has a valid objectId.

Hi, Oleg!

At the moment I cannot reproduce your issue. Can you please show part of code which retrieves NDevice from base?

Hi, Alexandr!

private void loginUser() {
    String password = NUser.i().password();
    if (password != null && !password.isEmpty()) {
        Backendless.UserService.login(password, password, new AsyncCallback<BackendlessUser>() {
            public void handleResponse(BackendlessUser user) {

            public void handleFault(BackendlessFault fault) {
                NoteMessage.showAlert("login fault", fault.toString());
                if (fault.getCode().equalsIgnoreCase("3003"))
        }, true);
    } else
        NoteMessage.showAlert("registration", "empty credentials");

Maybe we can use screenhero for debug?
my email:

Sometimes I have next error:

BackendlessFault{ code: ‘IllegalArgumentException’, message: ‘java.lang.Object[] cannot be cast to java.util.Map’ }

related problem:

Thank you for response, I see how you get the user, but I still cannot see how you retrieve device…
About the casting issue: I don’t think that it has same reasons, so we shall keep working in separate topics.

  1. I login

  2. Get user

  3. User have related field one to one with device with autoload checkbox.
    Please see attached screenshots at the top of topic.

  4. Then I use next:

NDevice device = (NDevice) user.getProperty("device");
        if (device == null)
            device = NUser.i().device();
        else {
            device = new NDevice();
        user.setProperty(Consts.DEVICE, device);
  1. save current user with error

What is NUser.i()? :slight_smile:

It is object from my app

maybe next will we more understandable:

NDevice device = (NDevice) user.getProperty("device");
if (device == null)
device = NUser.i().device();
else {
device = new NDevice();
device.setModel("Sony Z5");
user.setProperty(Consts.DEVICE, device);

So if the user contains NDevice, you create a new one, is it right?

not exactly, I want update NDevice if it exists.

If not exists I want to create new NDevice and save it at backendless

Will it help, If I will publish working sources of my project?

It will help a lot. You may send it to

Just sent to you, please check it and let me know that you got it.
I blocked with my project and I’m very sad.

Now that we have access to the project code, we should be able to resolve it quicker. I have tried it in my own example and could not reproduce (which means the server works as expected - I suspect there is something in the project).