From ce46e20efba053e914986f20e578d90ab2e42751 Mon Sep 17 00:00:00 2001
From: Boris Kolpackov person
objects. The call to persist()
is
where this assignment happens. Once this function returns, the
- id_
member contains this object's unique identifier.
id_
member contains this object's unique identifier.
+ As a convenience, the persist()
function also returns
+ a copy of the object's identifier that it made persistent. We
+ save the returned identifier for each object in a local variable.
+ We will use these identifiers later in the chapter to perform other
+ database operations on our persistent objects.
After we have persisted our objects, it is time to commit the transaction and make the changes permanent. Only after the @@ -1130,15 +1131,6 @@ main (int argc, char* argv[]) automatically be rolled back and all the changes made to the database undone.
-After the transaction has been committed, we save the
- objects' identifiers in local variables. We will use them later in this
- chapter to perform other database operations on our persistent
- objects. You might have noticed that our person
- class doesn't have the id()
function that we use
- here. To make our code compile we need to add a simple accessor
- with this name that returns the value of the id_
- data member.
The final bit of code in our example is the catch
block that handles the database exceptions. We do this by catching
the base ODB exception (see Section 3.8, "ODB
--
cgit v1.1