- inheriting from HibernateDaoSupport
- using HibernateTemplate
12/03/09
A case for the Generic lightweight DAO
This post stems from my research in how to correctly use hibernate3 in a spring-webmvc application. It outlines the various means to do so and proposes a rationale for using a generic lightweight DAO pattern.
I have been spending some time researching the various ways of using hibernate3 with spring in a web app.
The first thing I noticed is that there are multiple ways of doing that. The immediately obvious way is to inject the hibernate session factory in the various business components which would have to manipulate persistent data. This allows to work directly with the hibernate API, however it also means your business layer will become tightly coupled to Hibernate (think API usage all over the place) changing to a different orm later would be very hard. it also means code which is harder to test.
The common answer to that is to use the DAO pattern (Not everyone agrees, see the ORM and the misleading DAO pattern at the serverside ). Supposedly it helps with the decoupling by centralizing the API usage in one place. On the implementation side however things tend to get messier than the theory predicts.
Spring 2.5 proposes two ways to create DAO implementations :
Libellés :
pattern,
programming,
spring
Inscription à :
Publier les commentaires (Atom)

0 commentaires:
Enregistrer un commentaire