From 37e1d992d234363ff9aef45555678b5ee7203a99 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 1 Nov 2011 12:41:01 +0200 Subject: Implement support for optimistic concurrency New pragmas: optimistic, version. New test: optimistic. New database function: reload(). --- odb/database.txx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'odb/database.txx') 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 + void database:: + reload (T& obj) + { + // T should be object_type (cannot be const). + // + typedef odb::object_traits object_traits; + + if (!object_traits::reload (*this, obj)) + throw object_not_persistent (); + } + + template typename object_traits::pointer_type database:: find (const typename object_traits::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::erase (*this, id); object_traits::callback (*this, obj, callback_event::post_erase); } -- cgit v1.1