[odb-users] Inconsistency in documentation?

Boris Kolpackov boris at codesynthesis.com
Mon Feb 22 08:30:23 EST 2016

Hi Marcel,

Marcel Nehring <mne at qosmotec.com> writes:

> I am using sessions and the optimistic concurrency model. When I now want to
> discard local changes to persistent objects that I only performed in my
> local memory (i.e. overwrite my local state with the one from the database)
> I need to use ODB's database::load function taking a database ID and an
> object instance. I find it a bit strange that database::reload does not do
> this, but this is documented, so I guess there is a good reason for it.

When optimistic concurrency is enabled, reload() is meant to be used to
update the object's state but only if it has changed in the database.

> Anyhow, when using sessions, I thought that database::load always returns
> the current session's cached version.

Yes, if you call the version that returns a dynamically-allocated instance.
If you load into an existing instance, then it would be strange to return
something else.

> In 11.1 "Object Cache" it is stated, that "For as long as the session is
> in effect, any subsequent calls to load the same object will return the
> cached instance". In 3.9 "Loading Persistent Objects", however, it is
> stated that "In certain situations it may be necessary to reload the
> state of an object from the database [...] this is easy to achieve using
> the second load() function". Where "the second load function" is the one
> taking an ID and an existing instance.
> Ok, in 11.1 we speak of the same object being "returned" whereas the
> database::load() function's return type is void but this might be a bit
> subtle. At least I misunderstood it up until now.

I am still not sure where it is misleading. With the first version of
load() you say "load me an object with this id" and, if this object is
already in the cache, that's what's returned. In the second version
you say "load me an object with this id into this specific instance".
It would be strange to load it into some other instance (e.g., one
from the cache)?


More information about the odb-users mailing list