From d2c1f5f1a3063553483d09dec261efa44c6bc9bf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Jan 2013 14:50:26 +0200 Subject: Implement two-phase session insertion On the first step an uninitialized object is inserted into the cache as before (this is necessary to handle recursive loading). The second step is to notify the session that the object has been initialized. On this second step the session can perform change tracking preparations, such as make a copy of the object or reset the modification flag. New test: common/session/custom (implements a custom session that uses copies to track changes). --- odb/database.txx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'odb/database.txx') diff --git a/odb/database.txx b/odb/database.txx index df58f35..b5f9640 100644 --- a/odb/database.txx +++ b/odb/database.txx @@ -36,8 +36,11 @@ namespace odb object_traits::persist (*this, obj); - object_traits::reference_cache_traits::insert ( - *this, reference_cache_type::convert (obj)); + typename object_traits::reference_cache_traits::position_type p ( + object_traits::reference_cache_traits::insert ( + *this, reference_cache_type::convert (obj))); + + object_traits::reference_cache_traits::initialize (p); return object_traits::id (obj); } @@ -58,8 +61,11 @@ namespace odb // Get the canonical object pointer and insert it into object cache. // - object_traits::pointer_cache_traits::insert ( - *this, pointer_cache_type::convert (pobj)); + typename object_traits::pointer_cache_traits::position_type p ( + object_traits::pointer_cache_traits::insert ( + *this, pointer_cache_type::convert (pobj))); + + object_traits::pointer_cache_traits::initialize (p); return object_traits::id (obj); } -- cgit v1.1