[odb-users] Assertion fails in mysql/statement.cxx

Scott Deerwester scott.deerwester at gmail.com
Thu Dec 12 10:18:02 EST 2013


Thanks very much, Boris. One more question. What do I do if I need to get
an ordered list of the ChildClass ID's that are associated with a
ParentClass object? That was the motivation for using a QMap. I was using a
QMap iterator, but QSet doesn't do that. Any ideas?


On Thu, Dec 12, 2013 at 3:19 AM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi Scott,
>
> Thanks for sending the test case. The problematic part is this line:
>
> #pragma db not_null inverse(parent_)
> QMap<QString, QSharedPointer<ChildClass> > children_;
>
> An inverse container of pointers cannot be a map (remember that there
> is no table for an inverse container so there is no place to store the
> key). We should actually diagnose this in the ODB compiler and I've
> added this check for the next release.
>
> Once I've changed QMap to QSet, I ran into another problem in your
> code: since you have a bi-directional relationship between ChildClass
> and ParentClass, you need to use a session (object cache) when loading
> them. Otherwise ODB will keep loading them recursively until it runs
> out of stack:
>
>     transaction t(this->db->begin());
>
>     odb::session s;
>
>     QSharedPointer<ParentClass> parent;
>
>     if (!this->db->find<ParentClass>(aID)) {
>         qDebug() << "Failed to find parent" << aID;
>     }
>
>     t.commit();
>
> With these two fixes your test runs fine.
>
> Boris
>


More information about the odb-users mailing list