[odb-users] Object not persistent

Boris Kolpackov boris at codesynthesis.com
Tue Jul 5 09:26:15 EDT 2011

Hi Andreas,

Andreas Gerasch <gerasch at informatik.uni-tuebingen.de> writes:

> Persist is already working, but we have trouble while loading the  
> objects. We always get a odb::object_not_persistent error with most of  
> our objects, only very simple objects can be loaded.
> How can we find out what is going wrong?

I assume you are using the load() function to load an object given
its id. There are two things that determine what will be loaded
(and whether it will be found) when using this function:

1. Object type. This is what you specify in <> brackets after
   load, as in "load<person> (1);". The type determines the
   table in which ODB will look for the object.

2. Object id. This is the argument you pass to the load() function.

Both of these parameters have to be correct. If you think that the
object is in the database but load() still fails, then I suggest
that you connect to the database using the mysql client and see
if the object is indeed there. For example, you could run a
query like this:

select * from person where id = 1;

Here 'person' is the name of the table where the person objects
are stored (normally just the class name) and 'id' is the name
of the column that is the primary key (normally the name of the
data member designated as object id).

If this still does not help (i.e., you see the object in the
database but load() still fails), then I would need a small test
case that reproduces this problem.


More information about the odb-users mailing list