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 have found the way which works for me. I did not changed my json.
@DatabaseTable(tableName = SampleContract.Contributor.TABLE)
public class Contributor {
@DatabaseField(generatedId = true, columnName = SampleContract.Contributor._ID)
private int id;
@DatabaseField(columnName = SampleContract.Contributor.LOGIN)
public String login;
@DatabaseField(columnName = SampleContract.Contributor.CONTRIBUTIONS)
public int contributions;
@DatabaseField(foreign = true)
private ContributorsResult result;
@SuppressWarnings("serial")
@DatabaseTable(tableName = "contributor_list")
public static class ContributorsResult extends ArrayList {
@DatabaseField(id = true)
private int id = 0;
@ForeignCollectionField(eager = false)
private Collection result = this;
public Collection getResult() {
return result;
}
public void setResult(Collection result) {
if (result != null) {
this.clear();
this.addAll(result);
}
}
}
}