diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-10-27 15:16:49 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-10-27 15:16:49 +0200 |
commit | c9fa9d93a0db446eb8a85d62b106bff5e045ff28 (patch) | |
tree | 37b5f1ad7e814c3002211664a2334fea7d9d4213 /odb/oracle/object-result.txx | |
parent | b2d84383f0bdc81e690e53c700ec8c5fe8cd84e1 (diff) |
Add support for persistent classes without object ids
New pragma id (object). New test: common/no-id.
Diffstat (limited to 'odb/oracle/object-result.txx')
-rw-r--r-- | odb/oracle/object-result.txx | 94 |
1 files changed, 82 insertions, 12 deletions
diff --git a/odb/oracle/object-result.txx b/odb/oracle/object-result.txx index 5048601..e3eeca4 100644 --- a/odb/oracle/object-result.txx +++ b/odb/oracle/object-result.txx @@ -12,17 +12,21 @@ namespace odb { namespace oracle { + // + // object_result_impl + // + template <typename T> - result_impl<T, class_object>:: - ~result_impl () + object_result_impl<T>:: + ~object_result_impl () { } template <typename T> - result_impl<T, class_object>:: - result_impl (const query&, - details::shared_ptr<select_statement> statement, - object_statements<object_type>& statements) + object_result_impl<T>:: + object_result_impl (const query&, + details::shared_ptr<select_statement> statement, + object_statements<object_type>& statements) : base_type (statements.connection ().database ()), statement_ (statement), statements_ (statements) @@ -30,7 +34,7 @@ namespace odb } template <typename T> - void result_impl<T, class_object>:: + void object_result_impl<T>:: load (object_type& obj) { // This is a top-level call so the statements cannot be locked. @@ -66,15 +70,81 @@ namespace odb } template <typename T> - typename result_impl<T, class_object>::id_type - result_impl<T, class_object>:: + typename object_result_impl<T>::id_type + object_result_impl<T>:: load_id () { return object_traits::id (statements_.image ()); } template <typename T> - void result_impl<T, class_object>:: + void object_result_impl<T>:: + next () + { + this->current (pointer_type ()); + + typename object_traits::image_type& im (statements_.image ()); + + if (im.version != statements_.select_image_version ()) + { + binding& b (statements_.select_image_binding ()); + object_traits::bind (b.bind, im, statement_select); + statements_.select_image_version (im.version); + b.version++; + } + + if (statement_->fetch () == select_statement::no_data) + this->end_ = true; + } + + template <typename T> + void object_result_impl<T>:: + cache () + { + } + + template <typename T> + std::size_t object_result_impl<T>:: + size () + { + throw result_not_cached (); + } + + // + // object_result_impl_no_id + // + + template <typename T> + object_result_impl_no_id<T>:: + ~object_result_impl_no_id () + { + } + + template <typename T> + object_result_impl_no_id<T>:: + object_result_impl_no_id (const query&, + details::shared_ptr<select_statement> statement, + object_statements_no_id<object_type>& statements) + : base_type (statements.connection ().database ()), + statement_ (statement), + statements_ (statements) + { + } + + template <typename T> + void object_result_impl_no_id<T>:: + load (object_type& obj) + { + odb::database& db (this->database ()); + + object_traits::callback (db, obj, callback_event::pre_load); + object_traits::init (obj, statements_.image (), db); + statement_->stream_result (); + object_traits::callback (db, obj, callback_event::post_load); + } + + template <typename T> + void object_result_impl_no_id<T>:: next () { this->current (pointer_type ()); @@ -94,13 +164,13 @@ namespace odb } template <typename T> - void result_impl<T, class_object>:: + void object_result_impl_no_id<T>:: cache () { } template <typename T> - std::size_t result_impl<T, class_object>:: + std::size_t object_result_impl_no_id<T>:: size () { throw result_not_cached (); |