aboutsummaryrefslogtreecommitdiff
path: root/hello
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-11-30 18:47:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-11-30 18:47:05 +0200
commiteae9d8a277ab7d20228ac84bde36c75ef1d7b74d (patch)
tree0d45a8fed20be96b50b4d898fd6fafe536ed50a5 /hello
parentfe69aa1a2b29e577b86026f7bb56a19f5b3bdfef (diff)
Simplify hello example by using id returned from persist()
Diffstat (limited to 'hello')
-rw-r--r--hello/driver.cxx14
-rw-r--r--hello/person.hxx7
2 files changed, 5 insertions, 16 deletions
diff --git a/hello/driver.cxx b/hello/driver.cxx
index ad4ef57..61c3797 100644
--- a/hello/driver.cxx
+++ b/hello/driver.cxx
@@ -34,17 +34,13 @@ main (int argc, char* argv[])
transaction t (db->begin ());
- db->persist (john);
- db->persist (jane);
- db->persist (joe);
+ // Make objects persistent and save their ids for later use.
+ //
+ john_id = db->persist (john);
+ jane_id = db->persist (jane);
+ joe_id = db->persist (joe);
t.commit ();
-
- // Save object ids for later use.
- //
- john_id = john.id ();
- jane_id = jane.id ();
- joe_id = joe.id ();
}
typedef odb::query<person> query;
diff --git a/hello/person.hxx b/hello/person.hxx
index 7a939c7..69b1878 100644
--- a/hello/person.hxx
+++ b/hello/person.hxx
@@ -44,13 +44,6 @@ public:
age_ = age;
}
-public:
- unsigned long
- id () const
- {
- return id_;
- }
-
private:
friend class odb::access;