Update BackendlessCollection

Can we update the collection like below? It does not work. Thanks.

Backendless.Persistence.of(Person.class).find(dataQuery, new AsyncCallback<BackendlessCollection<Person>>() {
@Override
public void handleResponse(BackendlessCollection<Person> personBackendlessCollection) {
//loop through the return collection, set new values
for (Person person : personBackendlessCollection.getData()) {
person.setClass(“New class”);
person.setRoom(“New room”);
}
//save the updated collection
Backendless.Persistence.save(personBackendlessCollection, new AsyncCallback<BackendlessCollection<Person>>() {
@Override
public void handleResponse(BackendlessCollection<Person> personBackendlessCollection) {
}

        @Override
        public void handleFault(BackendlessFault backendlessFault) {

}
});
}
@Override
public void handleFault(BackendlessFault backendlessFault) {}
});

Hi, Key,

Could you please post the error you are currently receiving here?

This approach will not work. You can update either one object at a time. To update a collection of objects you can use one of the following approaches:

    Save the parent object with a collection of children objects which will be persisted/updated as well Use bulk update, but it is available only with the REST API (search for "bulk update" in the following document): http://backendless.com/documentation/data/rest/data_updating_data_objects.htm
Regards, Mark

It’s “unable to find method in class. method name save”.

I did use single row update and it worked, just wonder if we can update all rows at once.

Thanks.

You can using the “bulk update” feature which is available with the REST API. See my earlier response.

Regards,
Mark

Thank you but we don’t use Rest API at this point.

I understand, but if you need to update multiple objects with a single request, you can do it by either using the REST API call I described earlier or create your own service in Backendless API Engine and process the request on the server-side. With this approach you will make a single call on the client-side, but on the server, you will be saving objects one by one.

Great idea. Will do that. Thank you.

Mark,

I don’t know what happen to my Data Tab on the Backendless server. I got this message when click on Data tab under Users tab.

<html> <head><title>504 Gateway Time-out</title></head> <body bgcolor="white"> <center><h1>504 Gateway Time-out</h1></center> <hr><center>nginx/1.4.2</center> </body> </html> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page -->

Hi Key,

I can get to it just fine. Could you try clearing your browser cache (or try another browser) and see if you can open:

http://develop.backendless.com

Regards,
Mark

Thanks Mark but any other tabs was fine but not the Data one.

Is it still the same way? Could you attach a screenshot to show what it looks like?

http://support.backendless.com/public/attachments/80bcf208d7e00aa8d792a9fe41ff8d34.png</img>

Very strange. What is your application ID?