This example uses the ODMG C++ Binding and the ODMG Object Query Language (OQL). Other C++ bindings and query languages for object databases would be similar. Notice that all the code is C++, with the exception of the query string. You will not find a database sub-language in this example. The part in blue relates to the animation of transparent persistence (new window). More information on the ODMG specification (new window). Note that the same code would used for object-relational mapping products (new window). Transparent persistent interfaces work with both object database or object-relational mapping products.
d_Database db; d_Transaction txn;try { db.open("addressDB"); txn.begin();// perform query d_OQL_Query query( "select x from Person x where x.name = \"Doug Barry\""); d_Bag<d_Ref<Person> > allDougBarrys; d_oql_execute(query, allDougBarrys); d_Iterator<d_Ref<Person> > iter = allDougBarrys.create_iterator();// iterate over the results d_Ref<Person> p; while( iter.next(p) ){// do some addition processing on the person (not shown)// now traverse to the address object and update its value p->address.street = "13504 4th Avenue South"; }txn.commit(); db.close(); }//exception handling would go here ...
![]()
More on the general topic: How to access data in an object database


