users@glassfish.java.net

persistence recommendations for EJB apps?

From: Kristian Rink <lists_at_zimmer428.net>
Date: Fri, 20 Mar 2009 09:42:12 +0100

Folks;

in an EJB application I need to utilize SQL backend persistence in a way
that allows for retrieving data in a pretty "plain" way - either returning
Map<String,String> data if just one table row has been SELECTed, or
List<Map<String,String>> if more than one table row has been SELECTed, with
the column names in the corresponding table being keys of the Map and the
content of the corresponding cells in this row/cell. This kind of data
access should happen from within a stateless session bean exposing something
DAO'ish to the rest of the application structure.

There are three technologies in question for me to choose from in order to
solve this issue:

- The SimpleJdbcTemplate helper class of Spring Framework provides a
facility doing right this kind of data query, and this is what I am using in
a prototype right now because we so far still use Spring in other parts of
our application. Aiming for EJB3 however, I would like to keep dependencies
slim which is not what really is happening throwing in Spring.

- JPA and EntityManager, which would be my preferred approach (as it is
stock Java EE technology and we need O/R features as well in another, "new"
part of our application), seems to have functionality to do native SQL
queries returning Object's or Object[]s containing the "plain" table content
but not the table column names so it is just half of what I need at the
moment. So in here, I definitely would need some tweaking to make things
work the way they should.

- Using plain JDBC, which is simply around, eventually would address this
task at the cost of having to deal with pretty much "low-level" JDBC stuff
like connections et al so this is not really what I would like to go for but
eventually would do if anything else failed.

So, I am unsure whether to stay with the Spring helper code here, use JPA
and eventually some additional glue or throw away most of these dependencies
using just JDBC for this mess? Comments, anyone?

TIA and all the best,
Kristian


-- 
Kristian Rink
cell    :  +49 176 2447 2771
business: http://www.planconnect.de
personal: http://pictorial.zimmer428.net
"Past midnight. Never knew such silence.
The earth might be uninhabited..."
//beckett / krapp's last tape//