aboutsummaryrefslogtreecommitdiff
path: root/common/session/custom/session.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-01-18 10:23:39 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-01-18 10:23:39 +0200
commitd304a4b2b19dca115954f209d6a37a6958e73ab9 (patch)
tree0822a40a7d44e7921076b6ad458d29e3ad91c525 /common/session/custom/session.txx
parent856a438b33184959b64864f1afdf5a6a2fd6b0d2 (diff)
Add support for post-commit/rollback callbacks
New test: common/transaction/callback.
Diffstat (limited to 'common/session/custom/session.txx')
-rw-r--r--common/session/custom/session.txx11
1 files changed, 8 insertions, 3 deletions
diff --git a/common/session/custom/session.txx b/common/session/custom/session.txx
index fd90b6a..31c08c7 100644
--- a/common/session/custom/session.txx
+++ b/common/session/custom/session.txx
@@ -128,9 +128,10 @@ erase (odb::database&, const typename odb::object_traits<T>::id_type& id)
}
template <typename T>
-void session::object_map<T>::
+bool session::object_map<T>::
flush (odb::database& db)
{
+ bool r (false);
for (typename object_map<T>::iterator i (this->begin ()), e (this->end ());
i != e; ++i)
{
@@ -138,12 +139,16 @@ flush (odb::database& db)
if (d.state == changed || d.obj->changed (*d.orig))
db.update (d.obj); // State changed by the update() notification.
+
+ r = r || d.state == flushed;
}
+
+ return r;
}
template <typename T>
void session::object_map<T>::
-mark ()
+mark (unsigned short event)
{
for (typename object_map<T>::iterator i (this->begin ()), e (this->end ());
i != e; ++i)
@@ -151,6 +156,6 @@ mark ()
object_data<T>& d (i->second);
if (d.state == flushed)
- d.state = tracking;
+ d.state = event == odb::transaction::event_commit ? tracking : changed;
}
}