aboutsummaryrefslogtreecommitdiff
path: root/odb/database.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-01 12:41:01 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-01 12:41:01 +0200
commit37e1d992d234363ff9aef45555678b5ee7203a99 (patch)
tree0cb5e7066c02619233c1fde66f21b4704087b37b /odb/database.txx
parent7aee40f95c26ae3c5af2c723af57ba316f99cf0c (diff)
Implement support for optimistic concurrency
New pragmas: optimistic, version. New test: optimistic. New database function: reload().
Diffstat (limited to 'odb/database.txx')
-rw-r--r--odb/database.txx14
1 files changed, 13 insertions, 1 deletions
diff --git a/odb/database.txx b/odb/database.txx
index 42643aa..b019478 100644
--- a/odb/database.txx
+++ b/odb/database.txx
@@ -85,6 +85,18 @@ namespace odb
}
template <typename T>
+ void database::
+ reload (T& obj)
+ {
+ // T should be object_type (cannot be const).
+ //
+ typedef odb::object_traits<T> object_traits;
+
+ if (!object_traits::reload (*this, obj))
+ throw object_not_persistent ();
+ }
+
+ template <typename T>
typename object_traits<T>::pointer_type database::
find (const typename object_traits<T>::id_type& id)
{
@@ -206,7 +218,7 @@ namespace odb
typename object_traits::id_type id (object_traits::id (obj));
object_traits::callback (*this, obj, callback_event::pre_erase);
- object_traits::erase (*this, id);
+ object_traits::erase (*this, obj);
pointer_cache_traits<pointer_type>::erase (*this, id);
object_traits::callback (*this, obj, callback_event::post_erase);
}