unable to remove object

Unable to remove object.object with specified primary key does not exist !!
when trying to remove an object ???

Sorry, but with the information your provided it is impossible to diagnose the problem and moreover provide any kind of guidance.

See the doc on removing an object. (I cannot even provide a link to the doc since you didn’t say if it is Android, iOS, JS PHP, .NET or REST)…

i use android
i want to delete object i already inserted
fault message :-Unable to remove object.object with specified primary key does not exist !!
i think primary key is object id that backendless generate how can i get it in the code to delete this row ?

Hi, Fady!

When you get Backendless user with Backendless.UserService.CurrentUser() - does it contain objectId?
If it does, put it in the Student object before removing.

I have the same problem.

Backendless.Persistence.of( Product.class ).remove(p, new AsyncCallback<Long>() {
@Override
public void handleResponse(Long aLong) {
Toast.makeText(getApplicationContext(), “Product deleted”, Toast.LENGTH_SHORT).show();
}

@Override
public void handleFault(BackendlessFault backendlessFault) {
    Toast.makeText(getApplicationContext(), backendlessFault.getMessage(), Toast.LENGTH_SHORT).show();
    Log.e("handle", backendlessFault.getMessage());
}

});It always gets the “Unable to remove object. Object with the specified primary key does not exist” message.The product is loaded from backendless.

I can not reproduce your issue. Here it is my code

Backendless.Data.of( Product.class ).findFirst( new AsyncCallback&lt;Product&gt;()
{
  @Override
  public void handleResponse( Product product )
  {
    System.out.println("Product with name '" + product.getName() + "' was found" );
    Backendless.Data.of( Product.class ).remove( product, new AsyncCallback&lt;Long&gt;()
    {
      @Override
      public void handleResponse( Long aLong )
      {
        System.out.println( "Product was removed at " + new Date( aLong ) ) ;
      }

      @Override
      public void handleFault( BackendlessFault backendlessFault )
      {
        System.out.println("There was an error while removing product: " + backendlessFault.getMessage() );
      }
    } );
  }

  @Override
  public void handleFault( BackendlessFault backendlessFault )
  {
    System.out.println("There was an error while find first product: " + backendlessFault.getMessage() );
  }
} );

and result is


Product with name 'test' was found
Product was removed at Thu May 26 11:38:42 EEST 2016

my bad.

I have inserted the objectId and called remove class and still its showing the same i.e Unable to remove object, object with specifies primary key does not exis

Vidya, please provide an example of your code demonstrating the issue

After a few try and error methods, I have achieved it. First, when I retrieved objects from backendless table, I saved object id of every object. Later when I wanted to delete an obiect, I have called the save class and saved the object along with object id and then ,under on success method, I called remove class.It worked. I am not sure its just a round about solution or it is the way to do it.

Saving an object before its removing sounds redundant.
You should be able to delete an object by just knowing its objectId or by passing the whole object to remove method.
See an example from Sergey Kukurudzyak in this topic

I did the same but didn’t work for me

If it doesn’t work, please provide a complete code example which demonstrates the problem

In his method , he isnt calling remove method independently. He is calling findFirst which is retrieving an object and then removing it…two calls are being made. But if yo try to call remove method independently, its not working