Supposed I have the following class:
class Example {
List<ObjectA> objectsOfA;
List<ObjectB> objectsOfB;
List<ObjectC> objectsOfC;
....
}
I would usually have these tables:
Example(Id, other-attributes)ObjectA(some attributes, ExampleId)ObjectB(some attributes, ExampleId)ObjectC(some attributes, ExampleId)
If I want to restore an Example-object, I imagine I have two options:
- join every table together, resulting in a lot of entries and organizing it in hashmaps to reassemble the objects
- loading every
Exampleand for every example doing single requests for the lists ofObjectA,ObjectB,ObjectC.
If the number of Example-entries is low, option2 might be the best. But for every single entry in Example, I need to do x more requests where x is the number of tables in my class.
Otherwise, having everything in a single join requires me to reorganize all the data by myself - creating hashmaps, iterating through data and stuff, which is usually a lot of work in code.
I also get the possibility of lazy loading with option 2.
Do I have other choices? Did I miss something? (Of course I know about ORMs, but I decided to not use them on Android)