[odb-users] Re:Problem with object loading view

Andrew Cunningham odb at a-cunningham.com
Mon Mar 21 13:56:51 EDT 2016


>
> > One fairly simple workaround, for your case at least, would be to use a
> lazy pointer for the Foo relationship. The idea is to first load all the
> derived objects (so they all end up in the session).
> > Then have another loop that loads all the relationships. What do you
> think?
>
> I don't think this is a feasible solution for me. The example was greatly
> simplified. In reality there are many occasions where I do not load the
> objects explicitly but they get loaded due to (complex) object relations.
> Manually brachiating through all links to manually load the lazy pointers
> would mean a lot of overhead in my code.
>


Marcel,
Another approach you can use is to derive/implement a new type of lazy_ptr
that automatically loads the object (if needed) when you use the operator
-> or operator * on the lazy_ptr. That way you do not have any explicit
"loads".Of course is that you can only load an object in a transaction so
one needs to be careful when using the operators to only force an object
load in a transaction. Personally I wish this was the default mode of
operation of lazy_ptrs.

You can also use "sections" effectively to manage loading "sections" of
objects. That way you do not need to "micro-manage" loading of objects,
just those that reside in a section.

Andrew


More information about the odb-users mailing list