Is there any good generic JPA DAO implemenation?
16,726
Solution 1
You could take a look into the Spring Data JPA.
A few new concepts were introduced into Spring Data JPA, for instance the Query creation based on the method name, so you can declare a method like findById(String id)
and the "generic" implementation will interpret the method's name and execute something like select Entity from Entity where id = 'given string'
Methods like findByNameAndLastName(String name, String lastName)
or even findByNameOrInternalId(String name, int internalId)
are supported too.
Solution 2
Just wanted to mention a couple more generic dao implementations for JPA:
- Generic DAO toolkit - http://code.google.com/p/generic-dao/
- Related Question in SO - Single DAO & generic CRUD methods (JPA/Hibernate + Spring)
- A good blog article on JPA DAO - http://blog.xebia.com/2009/03/09/jpa-implementation-patterns-data-access-objects/
Author by
hoymkot
Updated on June 04, 2022Comments
-
hoymkot almost 2 years
According this article, generic JPA DAO(Data Access Object) is a pretty nice pattern.
Is there any good implementation?
-
Kevin Welker almost 12 yearsdefinitely look at this. I haven't used it but saw a seminar on it, and looked excellent.
-
Francisco Spaeth almost 12 years@KevinWelker: the idea is so cool, and if we take a look further is not that complicated, I was surprise that no one thought on that before...
-
hoymkot almost 12 yearsThe blog article is actually the same as the one I linked. :) T