Java and object databases |
|
This example uses the ODMG Java Binding and the ODMG Object Query Language (OQL). Other query languages for object databases would be similar. Notice that all the code is Java, 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. import org.odmg.*; import java.util.Collection; Implementation impl = new com.vendor.odmg.Implementation(); Database db = impl.newDatabase(); Transaction txn = impl.newTransaction(); try {
db.open("addressDB", Database.OPEN_READ_WRITE);
txn.begin(); // perform query
OQLQuery query = new OQLQuery(
"select x from Person x where x.name = \"Doug Barry\"");
Collection result = (Collection) query.execute();
Iterator iter = result.iterator(); // iterate over the results
while ( iter.hasNext() )
{
Person person = (Person) iter.next();// do some addition processing on the person (not shown) // now traverse to the address object and update its value
person.address.street = "13504 4th Avenue South";
} txn.commit();
db.close();
}//exception handling would go here ...
Related recent articles from Google News
More related news: java "object database" OR "object-oriented database" - Google News Related books at Amazon.com
More related books: Search Amazon.com for java object database
Copyright © 2000-2008 Barry & Associates,
Inc. All Rights Reserved.
| Information on becoming a sponsor
|
|