TechnoBuzz

A Techno Blog, mainly about Java

JDO 2.0 approval

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.

Advertisements

March 2, 2005 Posted by | JDO | Leave a comment

JCP rejects JDO 2.0

Link: Richard Monson-Haefel.

January 21, 2005 Posted by | JDO | Leave a comment

Toplink

Ive used hibernate, never have used Toplink.

January 13, 2005 Posted by | Hibernate & ORM, JDO | Leave a comment

JDO 2 Queries – Part 2

TheServerSide: "JDO 2 has overhauled the query support. "

November 12, 2004 Posted by | JDO | Leave a comment

JDO at JUG

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.

October 19, 2004 Posted by | EJB, JDO | Leave a comment

JDO 2.0 Queries – Part 1

JPOX supports JDO 2.0, here is some info on the JDO 2.0 queries.

September 28, 2004 Posted by | JDO | Leave a comment

JDO 2.0 with JPOX reccommendation

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”

September 9, 2004 Posted by | JDO | Leave a comment

Java Tutorials

Struts,JSTL,Hibernate

Exadel Java Topics

JDO, Struts, Java 1.5 etc.

September 1, 2004 Posted by | Hibernate & ORM, J2EE, JDO, Struts | Leave a comment

JPOX – gotchas

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.
//properties.setProperty(“org.jpox.autoStartMechanism”, “None”);
Now
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:

Transaction tx=pm.currentTransaction();
try
{
tx.begin();
Extent e=pm.getExtent(app.SAT.class,true);
Query q=pm.newQuery(e, “autonomic_score
q.setOrdering(“autonomic_score ascending”);
Collection c=(Collection)q.execute();
Iterator iter = c.iterator();
SAT sa;
while (iter.hasNext())
{
sa =(SAT)iter.next();
System.out.println(sa.autonomic_score);

}
System.out.println (“Done”);
tx.commit();

}
finally {pm.close();}

August 31, 2004 Posted by | JDO | Leave a comment

Another JPOX experience

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.

August 13, 2004 Posted by | JDO | Leave a comment

JPOX keys

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”/>

</class>

To configure a datastore identity class to use Auto-Increment (supported for db2) you simply add :
<class name=”myclass” … >
<datastore-identity strategy=”autoincrement”/>

</class>

August 5, 2004 Posted by | JDO | 1 Comment

JDO with JPOX

JPOX: a free and full compliant JDO implementation released under an open source license.
JPOX Tutorial

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.

package org.jpox.tutorial;
import org.jpox.*;
import java.util.Properties;
import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Transaction;
import model.Person;
public class Main
{
public static void main(String[] args)
{
// Properties for connection
Properties properties = new Properties();

properties.setProperty(“javax.jdo.PersistenceManagerFactoryClass”,”org.jpox.PersistenceManagerFactoryImpl”);
properties.setProperty(“javax.jdo.option.ConnectionDriverName”,”com.ibm.db2.jcc.DB2Driver”);
properties.setProperty(“javax.jdo.option.ConnectionURL”,”jdbc:db2://url:portnum/dsn”);
properties.setProperty(“javax.jdo.option.ConnectionUserName”,”db2inst1″);
properties.setProperty(“javax.jdo.option.ConnectionPassword”,””);
properties.setProperty(“org.jpox.autoCreateSchema”,”true”);
properties.setProperty(“org.jpox.validateTables”,”false”);
properties.setProperty(“org.jpox.validateConstraints”,”false”);

// PMFactory creation and getting the PM instance
PersistenceManagerFactory pmfactory = JDOHelper.getPersistenceManagerFactory(properties);
PersistenceManager pm = pmfactory.getPersistenceManager();

try
{
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.makePersistent(product);

pm.currentTransaction().commit(); // committing the transaction

}
finally
{
// if the transaction is still active, rolls it back
if( pm.currentTransaction().isActive() )
{
pm.currentTransaction().rollback();
}
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.

JDO vs SDO

JDO Implementations

OJB or now known as the apache db project.

July 25, 2004 Posted by | CommonJ, JDO | Leave a comment