[odb-users] How to make a "lazy" QList?

Rene Jensen rene at catatonic.dk
Fri Nov 2 08:36:12 EDT 2012


> On a more conceptual level, what seems to be the ultimate goal is
>> to have the ability to segment data members into lazy-loadable
>> sections. Supporting lazy loading for simple members will require
>> a separate statement for each member, if we do it member-by-member.
>> This is a significant overhead. So grouping members into as few
>> sections as possible is a good idea. Maybe something along these
>> lines:
>>
>> class Author
>> {
>>
>>   odb::lazy_section publications;
>>
>>   #pragma db lazy(publications)
>>   QList <QLazySharedPointer<Book> >    authorsBooks;
>>
>>   #pragma db lazy(publications)
>>   vector<QLazySharedPointer<Article> >  authorsArticles;
>>
>> };
>>
>> if (!A->publications.loaded ())
>>   A->publications.load (); // Loads authorsBooks and authorsArticles.
>>
>> Just some thoughts.
>>
>> Boris
>>
>
>
> This is an utterly brilliant idea in every conceivable way that I can
> immediately think of.
> Cheers
>
>
>

Hi again Boris.

Have you given any further thoughts to this? Automatic loading and saving
of lists of objects is increasingly becoming a pain.

The other day I had to change a simple property on an object containing a
QList<QWeakPointer<..some-class-M-to-M..>>
This was over a remote MySQL connection, and ODB started to go through the
complex operation of executing a ton of INSERT statements, one at a time.


I'm reading the manual right now, but I can't seem to find a trick in the
existing documentation.

Best regards,
Rene Jensen


More information about the odb-users mailing list