[odb-users] How to use 'session' to check if an object is already persisted?

Boris Kolpackov boris at codesynthesis.com
Tue Oct 15 10:23:51 EDT 2019

Justin Huang <yohuang at nvidia.com> writes:

> I read through https://codesynthesis.com/products/odb/doc/manual.xhtml#11.2
> but do not know how we can test if an object is persisted already in the
> session cache.

For context, this is a continuation of a thread started here:


The suggestion there was to use a session as an object cache to suppress
duplicate persists within the same transaction. If an object has session
support (the db session pragma), then when you persist it (with a call
to persist()), it will be automatically entered into the cache. So the
idea is to use session::cache_find() before calling persist() to check
if that has already happened.

More information about the odb-users mailing list