I have one to many relationship in local database. I am using ORMLite technology and my foreign object for one part is configured with foreignAutoRefresh = false.
@DatabaseTable(tableName = "Person")
public class Person{
@DatabaseField(generatedId = true)
private long id;
@DatabaseField
private String name;
@ForeignCollectionField
private Collection<Account> accounts;
}
Account:
@DatabaseTable(tableName = "Account")
public class Account{
@DatabaseField(generatedId = true)
private long id;
@DatabaseField
private String userName;
@DatabaseField(foreign = true, columnName =
"person_Id", foreignAutoRefresh = false)
private Person person;
}
List personList = personRuntimeDao.queryForAll();
The problem is that when ORMLite fetch the List with persons in the accounts for each person the foreign object is fetched too. And because that it leads to infinite recursion. There is no exception in the fetching but when I try to parse this List to Gson it throws me an exception - StackOverFlow because the List is infinite. When I read for foreignAutoRefresh I understand that when is configured to false, the foreign object needs to be NULL but it is not.
Is there anyone which could help me with this issue?