summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastian Schmelzer2012-07-05 11:58:47 +0200
committerSebastian Schmelzer2012-07-05 11:58:47 +0200
commit4b9b282de2fd04d0b79f6e2e9654cc7858930099 (patch)
treee08056c8a7af13f8847f258173269ddcc76e6618 /src
parentupdate pom (diff)
downloadxss-jpa-4b9b282de2fd04d0b79f6e2e9654cc7858930099.tar.gz
xss-jpa-4b9b282de2fd04d0b79f6e2e9654cc7858930099.tar.xz
xss-jpa-4b9b282de2fd04d0b79f6e2e9654cc7858930099.zip
add findall implementation to generic dao
Diffstat (limited to 'src')
-rw-r--r--src/main/java/nu/xss/jpa/dao/GenericJpaDao.java10
1 files 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<E,K> implements Dao<E,K>, Serializable {
}
public List<E> findAll() {
- // TODO Auto-generated method stub
- return null;
+ CriteriaBuilder cb = entityManager.getCriteriaBuilder();
+ CriteriaQuery<E> c = cb.createQuery(this.entity);
+ Root<E> root = c.from(this.entity);
+ c.select(root);
+ return entityManager.createQuery(c).getResultList();
}
}