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.

It's tricky?

I think my <a href= "http://www.rollerweblogger.org/page/roller/20021012#blogging_is_difficult"> Blogging is Difficult post was a little corny, overdone, and maybe gave people the wrong impressions. Writing things for my weblog is not difficult like some painful chore that I dread to do each day. It is quite the opposite. I enjoy it and sometimes I have to hold myself back.

What makes blogging difficult is that sometimes I write things that I later feel to be stupid and embarrasing. I think I'm being little too sensitive and self-conscious about this. My readers probably don't even notice the things that I consider to be stupid and embarrassing.

Another thing that makes blogging difficult is mixing the professional and the personal. Part of the reason that I write a weblog is professional. I want to improve my communication skills and I want to build a reputation as a software architect and developer. Again, I think I'm being too sensitive. I don't worry about the effect on my professional image of wearing shorts & berkenstocks, taking breaks for disc golf, and cranking up the Clash at work. So why should I care about having some fun on my weblog? As long as I don't mention my employer by name and I speak about work only in vague generalities, I'm fine - right?

I'll stop the meta-blogging/navel-gazing now and return you to my normal disjointed ramblings. That is what I promised and that is what I will deliver.

Main | Next day (Oct 14, 2002) »