[odb-users] Questions on object_not_persistent exception

Andrew Cunningham odb at a-cunningham.com
Fri Nov 3 13:44:51 EDT 2023


Hi Reilly,
With SQLite make sure you have PRAGMA foreign_keys=ON
Secondly using PRAGMA integrity_check to validate the database can be
helpful to isolate issues.
Andrew

On Mon, Oct 30, 2023 at 1:34 AM Reilly He <reillyhekazusa at gmail.com> wrote:
>
> Hi Boris,
>
> We recently encountered the '*object_not_persistent*' exceptions when using
> odb.
> After reading through the manual, especially the chapter:
>
>    - 3.9: Loading Persistent Objects
>    - 3.10: Updating Persistent Objects
>    - 3.11: Deleting Persistent Objects
>
> We know that we might R/U/D some ORM objects that do not exist in the
> database.
> But it is really hard to find the detailed biz logic which triggers this
> error.
>
> Based on the manual, the exception itself looks like this:
>
> > struct object_not_persistent: exception {
> >
> > virtual const char*
> >
> > what () const throw (); };
> >
>
> And based on the descriptions on the manual:
>
> > *Catching this exception guarantees that we will catch all the exceptions
> > thrown by ODB. The what() function returns a human-readable description of
> > the condition that triggered the exception. *
>
>
> We still find it not enough to quickly detect who triggers the exception.
>
> Do you know how to get more information when this exception happens? *Like
> the id, or the operation (R/U/D), or even the type of the Model?*
>
> Thanks a lot.
>
> Best Regards,
> Reilly He



More information about the odb-users mailing list