5

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

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

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

Here's 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?

1 Answers1

0

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

This stems from the fact that SQL does not support this behaviour. A 1-m (one to many) relationship between entities should be used instead. GreenDAO documentation: http://greenrobot.org/greendao/documentation/relations/#Modelling_To-Many_Relations

Maurice Gavin
  • 2,047
  • 1
  • 20
  • 26