Tuesday, May 16, 2006

 

Abstracting the persistence layer.

In this day and age, I'd like to be able to avoid having to write raw SQL (certainly at the development stage!), so I'm keen to be able to use whatever O/R mapping technologies there are available. The other benefit of this is that you don't tie yourself to any one particular database (the database becomes a "pluggable" component itself). I also personally find it a lot more natural to think in terms of objects, rather than table columns.

One of the things that piques my interest is the Java Persistence API (which is part of EJB 3.0). This states that you can leverage EJB 3.0 style persistence outside of an application server. I first heard about this in a tech talk with Gavin King from Hibernate. Persisting entities in this way makes a great deal of use of annotations, which really cuts down on the verbosity and enables you to do away with tricky XML descriptor files almost altogether (there's an interesting article about this here).

An entity becomes a simple POJO and so it should be clear what the class actually does; all the semantics concerning it's connections with an EJB container / application server are hidden away by marking up the relevant features with annotations. An alternative to using EJB 3.0 is Java Data Objects. This is another way of handling the O/R mapping and was always intended to be usable outside an application server. This (JDO 2.0) and EJB 3.0 have recently become more closely aligned. But some think that they will both exist as separate standards for some time to come (as can be seen with this
tech talk with Patrick Linksey from Solarmetric).

Some relevant standards that went final this month.


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?