[odb-users] queries during results iterations
Adnan RIHAN
axel50397 at gmail.com
Thu Apr 16 09:25:12 EDT 2015
Hello there !
I have an Invoice class and a Warehouse class.
An Invoice has a « type » property (among other types not interesting).
A Warehouse, in the database, only have 3 columns: open_date, open_time, closed_at. Each line are simply there to indicate when the user began to sell, and when he closed. The C++ model has a pointer (transient) to an Invoice.
There is no link between these 2 objects in database, BUT, when a day is closed, a particular Invoice (with a particular type = INVT) is created. And when I load a Warehouse, I have post_load callback which looks for the corresponding « INVT » type and loads it to the Warehouse’s invoice pointer.
When I query the Warehouse list, it loads the callback for each result, while iterating the results. So far, it’s what I want. But during the Warehouse list iteration, the first result is correctly loaded, it loads the post_load callback is correctly called (and executed in the same transaction as the iteration) then, it crashes on « ++i »...:
> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
> 0 libodb-sqlite-2.4.dylib 0x000000010fad41fa odb::sqlite::select_statement::next() + 10
> 1 com.yourcompany.LGC 0x000000010f8b3b2f odb::sqlite::object_result_impl<Warehouse>::next() + 95 (simple-object-result.txx:104)
> 2 com.yourcompany.LGC 0x000000010f8ba160 odb::result_iterator<Warehouse, (odb::class_kind)0>::operator++() + 32 (object-result.hxx:115)
> 3 com.yourcompany.LGC 0x000000010f8c5900 QOdbList<QSharedPointer<Warehouse> > EntityManager::all<Warehouse>(OrderBy, bool) + 576 (EntityManager.hpp:89)
Any idea? Is it because I execute it in the same transaction, or something like that? When I comment out the whole callback post_load, it doesn’t crash and there is no ODB exception. I hope I don’t need to play with multiple transactions :S
Thank you !
--
Cordialement, Adnan RIHAN.
GPG: 5675-62BA (https://keybase.io/max13/key.asc)
-> Si vous n'utilisez pas GPG mais souhaitez quand même m’envoyer un e-mail chiffré: (https://encrypt.to/0x567562BA).
More information about the odb-users
mailing list