Adding an array as a property in a greenDAO object

I have the following JSON response that I want to map to my entity:

{ "name": "Andrew", "stop_ids": [ "956", "957", "958" ] } 

I know that I can create relationships from one to many if I create another object with my stop_ids , but is there a way to map this directly?

Here is my code below, and I don't know how to directly map the array below as my property.

 Entity person = schema.addEntity("person"); person.addStringProperty("name"); person.addArrayProperty("stop_ids"); //what is the correct way to do this? 
+5
source share
1 answer

GreenDAO does not support adding arrays or lists of primitive types directly to an object. Source: https://github.com/greenrobot/greenDAO/issues/285

This is because SQL does not support this behavior. Instead, use 1 (one to many) relationships between objects. GreenDAO Documentation: http://greenrobot.org/greendao/documentation/relations/#Modelling_To-Many_Relations

0
source

Source: https://habr.com/ru/post/1240985/


All Articles