diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-26 13:24:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-11-26 13:24:00 +0200 |
commit | ba8430c002627705d559b5dd9d78ae7611476520 (patch) | |
tree | d629a51b81ed279a40172869a9130ce3ddbbe09c /odb/mysql/result.txx | |
parent | fba7f7853b4a9485fa2ee29189e4445252ccac97 (diff) |
Add support for recursive object loading
If an object of a type needs to be loaded recursively, then it is addded to
the delayed loading list which is processed once the statements are unlocked.
Diffstat (limited to 'odb/mysql/result.txx')
-rw-r--r-- | odb/mysql/result.txx | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/odb/mysql/result.txx b/odb/mysql/result.txx index bb1fe01..4b18abc 100644 --- a/odb/mysql/result.txx +++ b/odb/mysql/result.txx @@ -3,6 +3,8 @@ // copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include <odb/cache-traits.hxx> + namespace odb { namespace mysql @@ -26,14 +28,22 @@ namespace odb template <typename T> void result_impl<T>:: - current (object_type& x) + load (object_type& obj) { - object_traits::init (x, statements_.image (), this->database ()); + // This is a top-level call so the statements cannot be locked. + // + assert (!statements_.locked ()); + typename object_statements<object_type>::auto_lock l (statements_); + + object_traits::init (obj, statements_.image (), this->database ()); + + statements_.load_delayed (); + l.unlock (); } template <typename T> typename result_impl<T>::id_type result_impl<T>:: - current_id () + load_id () { return object_traits::id (statements_.image ()); } |