Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORMLite for Android doesn't autorefresh foreign object using foreignAutoRefresh

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.

like image 205
Andrea Sprega Avatar asked Feb 21 '23 07:02

Andrea Sprega


1 Answers

Edit:

So after creating some better unit tests and looking into this more, this turned out to be a bug. ORMLite was handling the maxForeignAutoRefreshLevel setting in the @DatabaseField annotation incorrectly. Right now (as you seem to have figured out looking at your answer) you need to add a foreignAutoRefresh = true and maxForeignAutoRefreshLevel = 3 to the C field in your B object and the D field in the C object as well. That should fix it.

I created the following bug report:

https://sourceforge.net/tracker/?func=detail&aid=3530801&group_id=297653&atid=1255989

I've fixed the problem in trunk and I've started the process of pushing out version 4.41. It's been a while since the last release and this is as good a time as any.

like image 74
Gray Avatar answered Mar 23 '23 00:03

Gray