I\'m using RoboSpice with Spring for Android and would like to persist a JSON array of objects with OrmLite. GSON is used for the JSON marshalling. With the default caching
I've found a work around to this problem. I added an extra result object which holds the array of objects. Off course this is only possible if you are able to manipulate the JSON. Still not really happy with this because I have introduce an useless class to my model.
So my the JSON looks like:
{
"id": 1,
"result":[{"id": 1, "title": "Test 1"},{"id": 2, "title": "Test 3"},{"id": 3, "title": "Test 3"}]
}
And I added the following class to hold the JSON result:
@DatabaseTable
public class FooResult {
@DatabaseField(id = true)
private int id;
@ForeignCollectionField(eager = false)
private Collection result;
// getters and setters
...
}
Also added the foreign relation the the Foo class:
@DatabaseTable
public class Foo {
@DatabaseField(id = true)
private int id;
@DatabaseField
private String title;
@DatabaseField(foreign = true)
private FooResult result;
// getters and setters
...
}