AW: [odb-users] object_already_persistent exception and polymorphic class

Marcel Nehring mne at
Fri Apr 29 10:14:29 EDT 2016

Hi Dieter,

sounds like you catch the exception and then commit the transaction anyway? You should not do that. If you do something like

    odb::transaction t(db.begin());
    db.persist(new employee("John"));
    db.persist(new employee("John"));
catch (const odb::exception& e)
    std::cerr << e.what () << endl;

then the transaction is rolled-back automatically because ODB's transaction class conforms to the RAII principle.
This should solve your problem.


More information about the odb-users mailing list