JDO 2.0 has been approved as the standard for object persistence within the JCP.
I have used the JPOX implementation which is an open source solution. I must say the feedback and support on that site is quite good.
If I had to choose between JDO and Hibernate I would choose JDO since Hibernate is strictly an O/R implementation at this point, and does not follow a specification like JDO does.
I made it to the JUG meeting on JDO/EJB3.0.
I was paying more attention to the JDO information. He mentioned that the object relational mapping (I guess from a design perspective) consists of two step process : mapping (easy part), then making it quick.
Also, he said that JDO works with J2EE, but does not require it. Another point was the JDO defers the datastore decisions. Meaning the spec does not call just for relational databases.
Last point was that 20-40% of JDBC persistence is spent on persistence infrastructure.
JMX and JDO 2.0: “If you’re looking to start working with JDO 2.0, I’d recommend JPOX (also see JPOX with Spring or Tapestry). Unfortunately, their implementation still requires you to “enhance” your classes at build-time”
I was having a problem in JPOX when I relocated some JPOX code into an new package. It would enhance just fine but when i went to invoke the code, it continued to refer to the old location. I described this here. The main thing I was not awrae of is that when you persist your data, there is this table called JPOX_TABLES which keeps track of the class to table mapping. This is where the problem was. By simply changing the row in JPOX_TABLES to point to the new class location, the problem went away.
In the JPOX runtime confg information page, it has an entry for the parameter org.jpox.autoStartMechanism. It allows JPOX to read in from some source the classes that it was persisting the previous time. By setting it to none, its starts from scratch each time.
that I undersatnd what is happening, i’ll leave the option alone which defaults to previous time configuration.
The next problem I encountered was related to using the jpox-1.1.0-alpha-2.jar or something. I was getting an exception when reading data in as noted here.
The error says : method getFetchPlan()Ljavax/jdo/FetchPlan; not found
Th news group mentions to take jdo.jar out of the classpath and it should work fine. I removed the file from WEB-INF/lib rebuilt the project, re-enhanced and it worked.
Following is the code I used to query the database with JPOX and parse the collection:
Query q=pm.newQuery(e, “autonomic_score
Iterator iter = c.iterator();
It appears Matt Raible liked using JPOX .
I like JPOX as well. It is pretty easy to get going with this JDO product. The documentation has alot of usefull information. The main problem I had using JPOX is when I renamed the class / table, the presistence manager was for some reason was complaining about the old class name even though I enhanced the class with the new name.
In running JPOX,
for the class element within the xml file, you have to specify a value for the identity-type attribute.
default is identity-type=datastorewhere you leave the aissignment of the IDs to JPOX.
The other choice is identity-type=applicationwhere the developer manages the specification of this identity.
Generating of unique ids for datastore identity is a mandatory.
The generation choices are via the database, JPOX provided poid routines, and user customized poid routines.
To configure a datastore identity class to use SequenceTablePoidGenerator you simply add :
<class name=”myclass” … >
<datastore-identity strategy=”factory” factory-class=”org.jpox.poid.SequenceTablePoidGenerator”/>
To configure a datastore identity class to use Auto-Increment (supported for db2) you simply add :
<class name=”myclass” … >
JPOX Install info:
Setting up the environment requires EMF, com.versant.eclipse.jdo_0.9.9_e2.zip, com.versant.eclipse.jdo.jpox_0.9.9_e2.zip.
You can download the the JPOX eclipsejdo.org plugins here .
I also grabbed the com.versant.eclipse.jdo.doc.user_0.9.9_e2.zip which I extracted and added the folder to eclipse plugin folder. Note that to access the help after the doc plugin is in effect, do help contents in eclipse.
For my project, needed following Jars: bcel.jar, btree.jar, db2jcc.jar, jdo.jar, jdo-ri.jar, jdori-enhancer.jar, jpox-enhancer.jar, log4j.jar. Instead of using the jpox jar, we referenced a different project which contained the jpox source. In the jpoc source project, had the ant.jar, bcel.jar, btree.jar, connector-api.jar, db2jcc.jar, jdo.jar, jdori.jar, jdori-enhancer.jar, jta.zip, log4j, and the oracle jars.
for the enhancer, I am running using WSAD. In run…, created a new application within my project. The class that is referenced is org.jpox.enhancer.JPOXEnhancer which executes on my projecting.jdo file (argument org/jpox/tutorial/package.jdo)
Reference the logging file to get info on how to set up log4j. I set up a JVM variable for my class : -Dlog4j.configuration=file:org/jpox/tutorial/log4j.properties
One thing to remember is to always run the enhancer after each compile.
Now, the main.java which performs the persistance. One thing I noticed when I ran the class is that it creates the table, but nowhere is the schema indicated. Something I need to find out how to specify.
public class Main
public static void main(String args)
// Properties for connection
Properties properties = new Properties();
// PMFactory creation and getting the PM instance
PersistenceManagerFactory pmfactory = JDOHelper.getPersistenceManagerFactory(properties);
PersistenceManager pm = pmfactory.getPersistenceManager();
pm.currentTransaction().begin(); // opening a transaction
Person dude = new Person(); // creates one Person
Product product=new Product(“Sony Discman”,”A standard discman from Sony”,49.99);
pm.currentTransaction().commit(); // committing the transaction
// if the transaction is still active, rolls it back
if( pm.currentTransaction().isActive() )
pm.close(); // close the PM
Some of the packages in the jpox jdo include: javax.jdo, org.jpox.
a thesis has been written
comparing JDBC to JDO
Object Identity provides training for the JDO API.
OJB or now known as the apache db project.