Generic JPA DAO/Repository Implementation

The DAO (aka Repository in Domain-Driven Design parlance) is a pervasive design pattern in server-side applications today. If you have a very large number of DAOs that are fairly homogenous/CRUD based, it can be very useful to have a generic version that you can then subclass as needed. German author and celebrated Java EE advocate Adam Bien actually took the time to create generic JPA based DAO code and generously share it with us all.

I encourage you to take a look and discuss the code, preferably with Adam (or here if you wish). If you are the open source hacker sort, you could even consider giving the code more airtime by adding it to a separate project perhaps under something like Apache DeltaSpike.


I don't really see the point in referencing this 4 year old blog post in the context of Java EE 6 or 7.

To create "Smart DAOs", I'd recommend

This is something like Spring Data, just without Spring.

Posted by Harald Wellmann on April 02, 2013 at 11:41 AM PDT #

Thanks for the excellent pointer, I'll try and highlight that ASAP. Honestly, the reason I dug that URL out is because I was recently debating Spring Data :-).

Posted by Reza Rahman on April 02, 2013 at 11:45 AM PDT #

The other recommend is DataValve.
The author is Andy Gibson.

Posted by ratking on April 02, 2013 at 08:28 PM PDT #

Many thanks, will look into it :-).

Posted by Reza Rahman on April 02, 2013 at 08:44 PM PDT #

As @Harald said, this is old stuff. Plus, I don't see the point of having a "Generic DAO" which is just a dumb, oversimplified delegation to entity manager (less safe typing etc.).

Posted by guest on April 03, 2013 at 11:56 PM PDT #

That happens to be my opinion exactly, but a lot of people appear to be staunch fans of Spring Data JPA, so it's good to have a more EE centric answer. It's even better that we already have more than one :-).

Posted by Reza Rahman on April 04, 2013 at 09:12 AM PDT #

Post a Comment:
Comments are closed for this entry.