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:55 +0200
commitecacd1fab70b761f3588165630c1ade7a88c0c24 (patch)
treec97685548b89d45d57a5d1fc08ce40adad5d4ac4
parent36946d9cee6698e0629c8d03e88f01238fd06410 (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/oracle/polymorphic-object-result.txx1
-rw-r--r--odb/oracle/simple-object-statements.txx11
2 files changed, 5 insertions, 7 deletions
diff --git a/odb/oracle/polymorphic-object-result.txx b/odb/oracle/polymorphic-object-result.txx
index 7635403..7fcb194 100644
--- a/odb/oracle/polymorphic-object-result.txx
+++ b/odb/oracle/polymorphic-object-result.txx
@@ -172,6 +172,7 @@ namespace odb
ce = callback_event::post_load;
pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
+ object_traits::pointer_cache_traits::initialize (ig.position ());
ig.release ();
}
diff --git a/odb/oracle/simple-object-statements.txx b/odb/oracle/simple-object-statements.txx
index 15c44fd..27a95e0 100644
--- a/odb/oracle/simple-object-statements.txx
+++ b/odb/oracle/simple-object-statements.txx
@@ -79,7 +79,7 @@ namespace odb
while (!dls.empty ())
{
delayed_load l (dls.back ());
- typename pointer_cache_traits::insert_guard g (l.pos);
+ typename pointer_cache_traits::insert_guard ig (l.pos);
dls.pop_back ();
if (l.loader == 0)
@@ -116,7 +116,8 @@ namespace odb
else
l.loader (db, l.id, *l.obj);
- g.release ();
+ pointer_cache_traits::initialize (ig.position ());
+ ig.release ();
}
}
@@ -124,11 +125,7 @@ namespace odb
void object_statements<T>::
clear_delayed_ ()
{
- // Remove the objects from the session cache. This is not the most
- // efficient way to do this (cache_traits::erase() will check for
- // a session on every iteration), but the delay vector won't be
- // empty only if something goes wrong (i.e., we are throwing an
- // exception).
+ // Remove the objects from the session cache.
//
for (typename delayed_loads::iterator i (delayed_.begin ()),
e (delayed_.end ()); i != e; ++i)