aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-01-09 14:50:26 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-01-16 07:42:56 +0200
commitf43bfd544372691933e7b5a0bd44ea66eb79266c (patch)
treeb8ec3f16dc976810de17a99b8035b29662219af1
parent5df8fc85147cc89f083f53d2b1ccd2d8fedaab29 (diff)
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).
-rw-r--r--odb/relational/source.cxx7
1 files changed, 5 insertions, 2 deletions
diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx
index 58e40e7..4fceb30 100644
--- a/odb/relational/source.cxx
+++ b/odb/relational/source.cxx
@@ -2006,7 +2006,8 @@ traverse_object (type& c)
else
os << "callback (db, obj, callback_event::post_load);";
- os << "}"
+ os << "pointer_cache_traits::initialize (ig.position ());"
+ << "}"
<< "else" << endl
<< rsts << ".delay_load (id, obj, ig.position ()" <<
(poly ? ", pi.delayed_loader" : "") << ");"
@@ -2089,8 +2090,9 @@ traverse_object (type& c)
if (delay_freeing_statement_result)
os << "auto_result ar (st);";
- os << "reference_cache_traits::insert_guard ig (" << endl
+ os << "reference_cache_traits::position_type pos (" << endl
<< "reference_cache_traits::insert (db, id, obj));"
+ << "reference_cache_traits::insert_guard ig (pos);"
<< endl
<< "callback (db, obj, callback_event::pre_load);"
<< "init (obj, sts.image (), &db);";
@@ -2104,6 +2106,7 @@ traverse_object (type& c)
<< rsts << ".load_delayed ();"
<< "l.unlock ();"
<< "callback (db, obj, callback_event::post_load);"
+ << "reference_cache_traits::initialize (pos);"
<< "ig.release ();"
<< "return true;";
}