Custom Business Logic Save Returns null

I am writing a custom business logic service and calling the Backendless.Persistence.save method. My code looks similar to this:

    CustomObject myObject = new CustomObject();
    myObject = Backendless.Persistence.save(newObject);       
    return myObject;

My data isn’t being saved and returning a null object. What could be the problem?

Thanks,
Phil

Hi Phil!
I can not reproduce this error message.
New object saved without errors via Custom Event Handler.
Could you try it again? Maybe some steps missing from issue description?
Regards,
Kate.

And just to clarify: do you use Hosted services or Custom Events Handlers?

I’m using Hosted Services. Still struggling with this problem. I’ll continue to take a look at it and keep you updated.

Hi Phil,

A couple of questions and observations about your code:

  1. Why do you create an instance of CustomObject and assign it to the “myObject” variable, when that variable’s value is re-assigned in the line right after?
CustomObject myObject = new CustomObject();
  1. What is “newObject” in the following line? How do you create that instance?
  2. Also, you might want to change the following line to "Backendless.Persistence.of( CustomObject.class ).save( newObject );
myObject = Backendless.Persistence.save(newObject);

Mark

  1. I removed the assigned instance.

  2. newObject is a parameter that is passed into the method.

  3. I changed the code to what you suggested.

And the result is…?

Oh. Still not working.

Can you post your code to show what you are doing? Please make sure not to omit anything and provide a clear picture so we can understand the full scope.

Regards,
Mark

I was able to fix my problem. I had 2 getter and setter methods returning and setting the same property and one of the table columns was a different type than the property type in my class.

Thanks for all your help. I’m really starting to like Backendless.