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.
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.
- JSR 244 Java Enterprise Edition 5 (Java EE 5).
- JSR 222 JAXB 2.0.
- JSR 243 Java Data Objects 2.0.
- JSR 220 Enterprise Java Beans 3.0.