Support Topics Documentation Slack YouTube Blog

Issue with bulk create in boolean fields


(Ryta Kulikowsky) #1

When I save a single object in my Android app using Backendless.Persistence.of(MyClass::class.java).save(object) is working fine.

But when I save multiple objects with Backendless.Persistence.of(MyClass::class.java).create(listObject) or Backendless.Data.of(MyClass::class.java).create(listObject), all boolean fields are saved in Backendless table as their default values (as setted in schema) and not as my values.

eg. if default value of column “isOnline” is FALSE and I set my object.isOnline = TRUE, the object is saved as FALSE.

application ID C7E4D6B0-688D-F07A-FF85-8F60722C2600

Thanks!


(Sergey Kukurudzyak) #2

@Ryta_Kulikowsky direct message are allowed only for the customers with payed support plan. So I will make your topic public if you do not mind?


(Ryta Kulikowsky) #3

ok i don’t mind


(Sergey Kukurudzyak) made this topic public #4

(Anton Govorushkin) #5

Hey @Ryta_Kulikowsky

Unfortunately we were not able to reproduce the behavior you described. What we’ve tried:

  1. REST request to create objects in bulk on a clean app
  2. Tried same on your application
  3. Tried 1 and 2 with and without default value for boolean property
  4. Tried via latest Android SDK

None of these steps resulted in that kind of error, boolean property was always set according to what value was in request. Code snippets below:

REST - curl -X POST -H 'Content-Type:application/json' 'https://api.backendless.com/<appID>/<restKey>/data/bulk/TestTable' -d '[{"isOnline":true}]'

List bulkList = new ArrayList();
        Employee employee = new Employee();
        employee.setOnline(true);
        bulkList.add(employee);


        Backendless.Data.of(Employee.class).create(bulkList, new AsyncCallback<List<String>>() {
            @Override
            public void handleResponse(List<String> response) {
                System.out.println(response);
            }

            @Override
            public void handleFault(BackendlessFault fault) {
                System.out.println(false);
            }
        });

I believe we’d need a minimal code sample of yours in order to reproduce the problem

Anton


(Ryta Kulikowsky) #6

This s my class:
data class Test (
var isOnline:Boolean?=null,
var nome:String?=null,
var objectId:String?=null
)

This is the code:
private fun setPointer() = GlobalScope.launch(Dispatchers.IO) {
val test = mutableListOf<Test>()
for (i in 1…10){
test.add(Test(i%2==0,“Hello, Backendless”))
}

Result on Debug:
test = {ArrayList@5394} size = 10
0 = {Test@5432} “Test(isOnline=false, nome=Hello, Backendless, objectId=null)”
1 = {Test@5433} “Test(isOnline=true, nome=Hello, Backendless, objectId=null)”
2 = {Test@5434} “Test(isOnline=false, nome=Hello, Backendless, objectId=null)”
3 = {Test@5435} “Test(isOnline=true, nome=Hello, Backendless, objectId=null)”
4 = {Test@5436} “Test(isOnline=false, nome=Hello, Backendless, objectId=null)”
5 = {Test@5437} “Test(isOnline=true, nome=Hello, Backendless, objectId=null)”
6 = {Test@5438} “Test(isOnline=false, nome=Hello, Backendless, objectId=null)”
7 = {Test@5439} “Test(isOnline=true, nome=Hello, Backendless, objectId=null)”
8 = {Test@5440} “Test(isOnline=false, nome=Hello, Backendless, objectId=null)”
9 = {Test@5441} “Test(isOnline=true, nome=Hello, Backendless, objectId=null)”

Result in Backendless:


(Oleg Vyalyh) #7

Hi, Ryta.
Have you tried to save list of objects using Java method?
As i understood you use Kotlin? So could you please to perform saving process with both languages to determine where the problem is?


(Ryta Kulikowsky) #8

I made the program in Java and persists the same error:

My Java class:

public class Test
{
private java.util.Date created;
private Boolean isOnline;
private String objectId;
private java.util.Date updated;
private String ownerId;
private String nome;

… getters and setters …
}

My Main activity:

private void setPointer() {
List<Test> tests = new ArrayList<>();

for (int i = 0; i<10;i++){
Test temp = new Test();
temp.setNome(“Hello, BackEndless”);
temp.setIsOnline(i%2==0);
tests.add(temp);
}

Backendless.Data.of(Test.class).create(tests, new AsyncCallback<List<String>>() {
@Override
public void handleResponse(List<String> response) {
Toast.makeText(MainActivity.this, “Yes”, Toast.LENGTH_SHORT).show();
}

@Override
public void handleFault(BackendlessFault fault) {
Toast.makeText(MainActivity.this, fault.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}

And the result in Backendless NULL

I can’t understand.
Please, help!


(Oleg Vyalyh) #9

I took your code and ran it on both my app and your app. All records have correct boolean value after saving.
Can i ask you to try with entirely new simple android app with only one Activity and only one method that perform creation and saving instances of ‘Test’ class.
if the problem is still reproduced, please send us this simple project entirely as is.


(Ryta Kulikowsky) #10

That is exactly what I did.
I’m using last backendless api 5.2.4 and Android Studio 3.4.1.
https://drive.google.com/open?id=1Mk-QVf-duT_-Cb8RTHFfWaQoPy1lm4cD
Here is the entire project


(Ryta Kulikowsky) #11

Any news in my issue?:disappointed_relieved: