I have a custom view that loads a model object (let's call it Person, why not). These objects are stored in a DB, obtained through a Loader and inserted into a ListView through a CursorAdapter that instantiates said views. So far, so good.
Now, Person has a reference to another model object, let's say Country. Countries are in its own table, and I need the name of the country (having the ID, of course) to represent it in the list items.
I see three options:
Query the database from the view method that loads the Person data (
setPerson()?).Deep pre-load (I think I just made a term up, sorry) my model objects with the Country information.
Request that the Country data be asynchronously queried and then brought back to the UI.
The problem with (1) is that the UI may block. The problem with (2) is that it leads to heavy data duplication in memory. The problem with (3) is that it complicates flow, maybe unnecessarily.
What should I do? Is the performance hit of (1) important? Maybe (1), query the data from the View, but implement a cache to avoid hitting the database repeatedly for the same Country? Maybe (2), with said cache layer to ensure instances of the object are unique? A 4th option I haven't considered? What do ORMs do?
Thanks!