A Techno Blog, mainly about Java

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”);
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();
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);

System.out.println (“Done”);

finally {pm.close();}

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