Problem updating relation one-to-many

I have two tables, A and B with the following feature.

Table A has a column called B_OBJECTS, which relates an object of table A with one or more objects of table B.
So there is a relation one to many between A and B, described by the column B_OBJECTS in table A.

When i try to update the list of B objects in B_OBJECTS, i have a weired behaviour.

I update the A object retriving it by a findById query, then i modify the B_OBJECTS list containing the B objects related with A.
During debug the A object is correctly modified, but when i run the Backendless.Data.of(A.class).save(this), the returned A object has the B_OBJECTS attribute set to null.

It’s pretty weird because i run the same istructions on other tables with the same relations (one to many) and it works fine.

Here you are the code for loading the already existing A object and updating it:

A aToUpdate = Backendless.Data.of(A.class).findById(objectId, 1);

if (aToUpdate != null)

    A updatedA = aToUpdate.update(jsonnedData);

And here is the update method implemented in the A class:

public A update(JSONObject json) {

    try {

        if (json.has("name"))
   = json.getString("name");
       if (json.has("idB_OBJECTS") && json.getJSONArray("idB_OBJECTS").length() > 0) {

            JSONArray jsonArray = json.getJSONArray("idB_OBJECTS");
            StringBuilder whereClause = new StringBuilder();

            for (int i = 1; i < jsonArray.length(); i++)
                whereClause.append(" OR ").append("objectId='").append(jsonArray.getString(i)).append("'");

            BackendlessDataQuery dataQuery = new BackendlessDataQuery();

            List&lt;B&gt; bList= Backendless.Persistence.of(B.class).find(dataQuery).getData();

            if (bList!= null && !bList.isEmpty()) {
                if (this.B_OBJECTS!= null)
                    this.B_OBJECTS = new ArrayList&lt;&gt;();
    } catch (BackendlessException e) {

    return Backendless.Data.of(A.class).save(this);;

Can you help me?



In order to update relations, you’ll first need to load them. Please see the documentation here:

I’ve done that, as you can see I load my data with a findById(id, 1).

Therefore the relations are loaded properly.
Maybe there is something esle, but I don’t know what…

It might be that the fault is with me, I really don’t know!