[odb-users] _cache_persist not called

Boris Kolpackov boris at codesynthesis.com
Tue Jun 9 09:40:15 EDT 2015


Hi Konstantin,

Konstantin Tarovik <konstantin.tarovik at ab-soft.net> writes:

> Looks like the problem arises when I use smart pointers (i.e.
> #pragma db object(Conversation) pointer(std::shared_ptr) ).

Ok, I think I know what's going on. If you use shared_ptr
(or any other smart pointer) as an object pointer, the
session no longer caches objects that were passed to
persist() by reference (since we cannot assume it's ok to
use the reference to initialize the smart pointer). In
other words:

shared_ptr<object> o = ...;

db.persist (*o); // Not cached.
db.persist (o);  // Cached.

Boris



More information about the odb-users mailing list