I am currently working on a JEE-5 project using Spring and EJB3/Hibernate. When it comes to encapsulate the access to a database the DAO pattern is used. But it has some drawbacks:
If you want to write a typesafe DAO you must repeat yourself over and over again, writing almost the same DAO code for each and every business object. Of course, you can make the DAO a generic one, but then you are loosing type safety. But there is a better way since JDK5 introduces generics.
At the W-JAX in Munich Adam Bien talked about a very good article on IBMs developer site called "Don't repeat the DAO". If you want to implement a generic and typesafe DAO using Spring and Hibernate you have to check it out at:
Another good example using plain Hibernate/EJB3 can be found on the Hibernate page under http://hibernate.org/328.html.