HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

"How to Store & Share Your Java Objects"
Vol. 3, Issue 4, p. 8


Listing 1: Examples of Java use of ODBMS.
//a persistent class with a transient attribute  
public class Person {  
public String name;  
transient Something currentSomething;  

// Opening a database  
public static Database open(String name, int accessMode)  
throws ODMGException;  
public void close() throws ODMGException;  

//standard java code applies for accessing objects  

//example code using collections and OQL queries  
SetOfObject mathematicians;  
mathematicians = Students.query(  
"exists s in this.takes: s.section_of.name = \"math\" ");  

Bag mathematicians;  
Bag assistedProfs;  
Double x;  
OQLQuery query;  
mathematicians = Students.query(  
"exists s in this.takes: s.sectionOf.name = \"math\" ");  
query = new OQLQuery(  
"select t.assists.taughtBy from t in TA where t.salary > $1 and t in $2 ");  
x = new Double(50000.0);  
query.bind(x); query.bind(mathematicians);  
assistedProfs = (Bag) query.execute(); 

All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.