aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/database.hxx6
-rw-r--r--odb/database.txx15
2 files changed, 19 insertions, 2 deletions
diff --git a/odb/database.hxx b/odb/database.hxx
index ab80da4..4858f0f 100644
--- a/odb/database.hxx
+++ b/odb/database.hxx
@@ -35,6 +35,10 @@ namespace odb
//
template <typename T>
typename object_traits<T>::id_type
+ persist (const T& object);
+
+ template <typename T>
+ typename object_traits<T>::id_type
persist (T& object);
// Throw object_not_persistent if not found.
@@ -61,7 +65,7 @@ namespace odb
//
template <typename T>
void
- update (T& object);
+ update (const T& object);
// Make the object transient. Throw object_not_persistent if not
// found.
diff --git a/odb/database.txx b/odb/database.txx
index f5449b6..a94f471 100644
--- a/odb/database.txx
+++ b/odb/database.txx
@@ -10,6 +10,19 @@ namespace odb
{
template <typename T>
typename object_traits<T>::id_type database::
+ persist (const T& obj)
+ {
+ typedef object_traits<T> traits;
+
+ if (!transaction::has_current ())
+ throw not_in_transaction ();
+
+ traits::persist (*this, obj);
+ return traits::id (obj);
+ }
+
+ template <typename T>
+ typename object_traits<T>::id_type database::
persist (T& obj)
{
typedef object_traits<T> traits;
@@ -64,7 +77,7 @@ namespace odb
template <typename T>
void database::
- update (T& obj)
+ update (const T& obj)
{
if (!transaction::has_current ())
throw not_in_transaction ();