Open source reader

Wednesday, May 17, 2006

A generic typesafe DAO with Hibernate and Spring AOP

Per Mellqvist wrote an article on dao driven by generics.
Here is what you'll read:
  1. The DAO implementation
  2. A generic DAO interface
  3. Implementing the interface
  4. The Spring configuration
  5. A usable generic DAO
  6. Spring AOP introductions
  7. Extending GenericDAO
  8. Configuring PersonDao
  9. Hibernate named queries
  10. A step-by-step overview
  11. A reusable DAO class
  12. The executeFinder() method
  13. In conclusion
DAO ? :)
The DAO pattern should be well known to any enterprise Java developer. Implementations of the pattern vary considerably, however, so let's clarify the assumptions behind the DAO implementation I present in this article:
  • All database access in the system is made through a DAO to achieve encapsulation.
  • Each DAO instance is responsible for one primary domain object or entity. If a domain object has an independent lifecycle, it should have its own DAO.
  • The DAO is responsible for creations, reads (by primary key), updates, and deletions -- that is, CRUD -- on the domain object.
  • The DAO may allow queries based on criteria other than the primary key. I refer to these as finder methods or finders. The return value of a finder is normally a collection of the domain object for which the DAO is responsible.
  • The DAO is not responsible for handling transactions, sessions, or connections. These are handled outside the DAO to achieve flexibility.
Damn ... another gazillion way of doing DAO :)


Post a Comment

<< Home