Support Topics Documentation Slack YouTube Blog

Update table fails


(Alex Sh) #1

Hello,
i have a problem adding new entity to the table.
cat is member of type Category, filled by upper function.
Here is my save code:

Backendless.Persistence.save( cat, new AsyncCallback<Category>() {
        public void handleResponse( Category savedCategory )
        {
            DataHolder.getInstance().addCategory(savedCategory);
        }
        @Override
        public void handleFault( BackendlessFault fault )
        {
            // an error has occurred, the error code can be retrieved with fault.getCode()
        }
    });

I get following response :

“Unable to save entity, properties: Name cannot be null”
faultCode 1037.

As i can see in debugger before it activates save, the Name field of the entity has string value.
What can be the problem?

Alex.

P.S.
The following worked with BE4.


(Vladimir Upirov) #2

Hi Alex
Did you try to create a new Category object via our REST Console in DevConsole -> Data -> CategoryTable -> REST Console?

And also could you please provide your appId

Regards, Vlad


(Alex Sh) #3

Hi Vlad,
I didn’t tried this.
I found the temporary workaround - disable constraint Not Null for the Name field.
The field Name in the SCHEMA has STRING data type. Is it possible that your system does not detects Android’s java type string as Table STRING ?
How can i send you the appid privately ?


(Vladimir Upirov) #4

You can share your appId right here.


(Alex Sh) #5

I wouldn’t like to share my appid on WWW.
Can i send it to you i some hidden way ?


(Vladimir Upirov) #6

yes, you can, just send a new message to staff user
Update%20table%20fails%20-%20Android%20-%20Backendless%20Support%20Forum%202018-09-26%2010-56-12


(Vladimir Upirov) #7

Got it,
Can I enable NOT-NULL constraint for Name column in Category table and try to create a new Category with REST-Console?


(Alex Sh) #8

Yes, you can.

Regards,
Alex.


(Alex Sh) #9

Hi Vlad,
Any foundings?

Alex.


(Sergey Kukurudzyak) #10

name of your column starts from upper case, so your model should be:

public class Category
{
  private String Name;

  @MapToProperty( property = "Name" )
  public Date getName()
  {
    return Name;
  }

  public Category setName( String Name )
  {
    this.Name = Name;
    return this;
  }
}

because with out @MapToProperty( property = "Name" ) java(android) inspector will serialize Name as name then server will not be able to find property Name


(Alex Sh) #11

Hi Sergey,
I’m using the java classes that has been generated by the Backendless code generator.
The generated class contains the functions you wrote, but it doesn’t contains the line

Not for this field and not for others.
The only mapping i have is:

Backendless.Data.mapTableToClass( “Category”, Category.class );

in the beginning of my app.
Do i have to add the @MapToProperty for each field of each table i use ?

Regards,
Alex.


(Sergey Kukurudzyak) #12

Yes, you have to, if your column name starts from upper case


(Alex Sh) #13

Thank you very much, Sergey, it worked.

Regards,
Alex.