Someone faced the problem of Ormlite and Gson, Gson cannot work with ForeignCollection. How did you solve this problem?

My class to turn into json

public class Building { @DatabaseField(dataType = DataType.INTEGER, columnName = "id", generatedId = true) private int id; @DatabaseField(dataType = DataType.STRING, columnName = "name") private String address; @ForeignCollectionField(eager = true) private ForeignCollection<Person> persons; } public class Person { @DatabaseField(dataType = DataType.INTEGER, columnName = "id", generatedId = true) private int id; @DatabaseField(dataType = DataType.STRING, columnName = "name") private String name; @DatabaseField (foreign = true, foreignAutoRefresh = true) public Building building; } 
  • and what is the problem ?, after serializing persons == null? - Chaynik
  • add an empty constructor to the person class. public person () {} and do the same in Building - Chaynik

0