From 4b9b282de2fd04d0b79f6e2e9654cc7858930099 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Thu, 5 Jul 2012 11:58:47 +0200 Subject: add findall implementation to generic dao --- src/main/java/nu/xss/jpa/dao/GenericJpaDao.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/nu/xss/jpa/dao/GenericJpaDao.java b/src/main/java/nu/xss/jpa/dao/GenericJpaDao.java index e282911..f752aef 100644 --- a/src/main/java/nu/xss/jpa/dao/GenericJpaDao.java +++ b/src/main/java/nu/xss/jpa/dao/GenericJpaDao.java @@ -6,6 +6,9 @@ import java.util.List; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,8 +44,11 @@ public abstract class GenericJpaDao implements Dao, Serializable { } public List findAll() { - // TODO Auto-generated method stub - return null; + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaQuery c = cb.createQuery(this.entity); + Root root = c.from(this.entity); + c.select(root); + return entityManager.createQuery(c).getResultList(); } } -- cgit v1.2.3-55-g7522