« It's tricky? | Main | Career Redux »

Java Persistence Frameworks, again

... and that is just a few of the recent posts ...

The topic of Java persistence frameworks just keeps on trucking through the Java blogs.  I think that the reason the topic keeps coming up is that there is no clear concensus on the "right way" to do persistence. I certainly don't know the right way. But anyway...

I'd like to understand the available tools a little better, so I've started looking at the tools mentioned in the above posts.  I found the feature comparison on the Cayenne project's Wiki to be helpful and I also found a very nice set of Java persistence framework development scenarios on the Hibernate website.  The Hibernate folks have outlined four development scenerios for using a Java persistence framework: top-down, bottom-up, middle-out, and meet-in-the-middle.  Here is my generalized description of these four scenarios, plus a fifth "generic-object" approach that I have added to accomodate OFBiz-EE:

Top-down: Start with an existing JavaBeans object model, develop a mapping that maps those objects to tables in your database, generate DDL to create your database, and then use a persistance API to persist those objects to that database.

Bottom-up: Start with an existing database schema, describe your database schema using using XML or some other meta-data representation, generate your JavaBeans object model, optionally add business logic to those objects, and use a persistence API to store and retrieve your objects.

Middle-out: Start with a meta-data description of your object model, generate your JavaBeans object model, generate DDL to create your dataBase, and use a persistence API to store and retrieve your objects.

Meet-in-the-middle: Start with an existing database schema and an existing JavaBeans object model, develop a mapping to map between the two, and use a persistence API to store and retrieve your objects.

Generic-object: Start with a meta-data description of your desired database schema, generate DDL to create your database, and use a persistence API to store and retrieve generic data objects, with values stored as a hash of name-value pairs, to and from your database.


I think the Hibernate guys have really nailed it.  Every tool I have seen supports one or more of these scenarios.  So I decided to use these scenarios as a way to compare the available Java persistence frameworks.  I started to build a table to compare the scenarios supported by the various persistence frameworks and some other factors that I think are important interesting (thanks ceperez): support for the JDO API, support for ODMG API, development activity, and database support.  

Here is the first cut of my comparson table, I will be trying to complete it over the next couple of days:

<table cellpadding="0" cellspacing="0" border="1" padding="2px" style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;"> <td valign="middle" style="background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">
<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" align="left" height="30">Abra

<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">Castor
JDO
<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">Cayenne <td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255);"><a href="http://jakarta.apache.org/commons/sandbox/sql/" style="font-weight: bold;">Commons
SQL
<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">Hiber
-nate
<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">Jakarta
OJB
<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">OFBiz
EE
<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">Jakarta
Torque

<td valign="middle" style="text-align: center; background-color: rgb(204, 204, 255); font-weight: bold;" bgcolor="#ccccff" height="30">TJDO <td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">Top-down <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">Bottom-up <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">N
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">Middle-out <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">Meet-in-middle <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">N <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">N
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
Generic-object






Y


<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">JDO API
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">soon <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">N
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="font-weight: bold; background-color: rgb(238, 238, 238);">ODMG3 API
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">subset
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">N
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">N
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">Y
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">Y
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">N
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">N
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">License <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">BSD <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">BSD <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">BSD
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">APL
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">LGPL
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">APL
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">BSD <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">APL <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">APL
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">Last release <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">0.9.6
Sept
2002
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">0.9.4.1
November
2002
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">1.0a3
Sept
2002
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">1.1.4-b
Oct
2002
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">2.0-b2
July
2002 <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">2.0-b
Sept
2002
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">SF Activity
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">19.4% <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">-
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">98.3%
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">- <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">99.9%
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">- <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">98.9% <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">- <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">95.3%
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">SF Downloads <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">7
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">-
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">2698
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">-
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">775
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">- <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">86869
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">- <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">278
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">Developers <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">3
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">3
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">3
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">11
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">17
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">11 (1)
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">10 (2)
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">7
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">MySQL <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">PostgreSQL <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">HSQL <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">Oracle <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">SQL Server <td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="font-weight: bold; background-color: rgb(255, 255, 255);">DB2 <td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">Y
<td valign="middle" style="text-align: center; background-color: rgb(255, 255, 255);">
<td valign="middle" style="background-color: rgb(238, 238, 238); font-weight: bold;">Sybase
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="text-align: center; background-color: rgb(238, 238, 238);">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">Y
<td valign="middle" style="background-color: rgb(238, 238, 238); text-align: center;">

Footnotes:
  1. There are 11 developers on OFBiz, not sure how many really work on the Entity Engine
  2. There are 10 developers on Turbine, not sure how many really work on Torque
Other notes:
  • I took JGrinder and JRF out of he mix because they seem to be a little too intrusive.  They force your to make your persistent objects extend framework objects and they don't seem to offer any tools to help you generate DDL or persistent objects.
  • I'm going to limit myself to open source frameworks for the time being, but I'd also like to consider Oracle's TopLink, CocoBase, Oracle's BC4J, and the commercial JDO implementations.  
  • I'm also going to ignore EJB CMP for now.
  • Blank cells still need to be filled in and hints are appreciated
  • A dash "-" indicates "not applicable.
By the way, Roller uses the bottom-up approach.  Roller uses Castor, but not the Castor Source Generator.  Instead, Roller uses XDoclet to generate the persistent data objects, Struts form beans, and the Castor Mapping file all from the same source meta-data.  The Castor/XDoclet combo is not perfect, but I still don't know that moving to a new framework would be an improvement.  We might just be exchanging one set of idiosyncracies for another set.

Comments:

To the author of the v. useful persistence comparison table... If you have encountered it, I'd value your opinion on Expresso (open source framework hosted at www.jcorporate.com - persistence and more - pretty active in terms of developers and downloads), because you have definitely seen more of life than me! I think it does top-down & bottom-up reasonably well. No, they don't pay me. Many thanks, David.

Posted by David Bridgewater (Leeds, UK) on December 08, 2002 at 07:04 PM EST #

To the author of the v. useful persistence comparison table... If you have encountered it, I'd value your opinion on Expresso (open source framework hosted at www.jcorporate.com - persistence and more - pretty active in terms of developers and downloads), because you have definitely seen more of life than me! I think it does top-down & bottom-up reasonably well. No, they don't pay me. Many thanks, David.

Posted by David Bridgewater (Leeds, UK) on December 08, 2002 at 07:06 PM EST #

I've worked with OJB, primarily with mySQL, and I love it. A little difficult learning curve, but the object cache is incredible... just thought I'd correct a few mistakes in the table: 1) OJB supports HSQL, in fact the Hypersonic engine is the default selection for the RDBMS. 2) OJB supports MS SQL. Support for GUID columns as identities is a little tricky, but there is some good help on the Apache ojb-user mailing list archive.

Posted by Aaron on August 17, 2003 at 03:24 AM EDT #

I agree with Aaron. (Wow, didn't realize this was that old). Anyway, the last release of OJB was Dec 14, 2003: http://db.apache.org/builds/ojb/

Posted by Dan Moore on February 25, 2004 at 08:14 PM EST #

very helpful and informative article

Posted by aleegadget on May 19, 2024 at 02:46 PM EDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« It's tricky? | Main | Career Redux »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Java, some may be related to this entry.