ORMLite for Android doesn't autorefresh foreign object using foreignAutoRefresh

android, foreign-keys, java, ormlite

Solution

I solved the issue by adding the annotation attribute `maxForeignAutoRefreshLevel = 3` on the C entity, and D gets now refreshed.

The strange thing is that I didn't need to set maxForeignAutoRefreshLevel in neither A, B or D.

Another detail is that if I set to 2 the level for the C entity, D doesn't get refreshed anymore. Seems like the `maxForeignAutoRefreshLevel = 3` gets applied from the C entity to the "starting" entity, in my case A.

Problem

Here's my problem: I have different entities linked to others up to a nesting depth of 3. All my foreign fields in every object are annotated with ``` @DatabaseField(foreign = true, foreignAutoRefresh = true) ``` But only up to a nesting depth of 2 I get actual autoRefreshed foreign objects. For example, if I query for an A entity and then I do: ``` A.getB().getC().getD() ``` for entities B and C I already have all the fields, while for entity D I only have the ID fetched and I need to call the dao.refresh() method in order to fetch all of the D fields. Is it a limitation? I can't find anything about it on the documentation.

Original source