diff --git a/modules/dbsupport/src/main/java/org/jpos/ee/DBManager.java b/modules/dbsupport/src/main/java/org/jpos/ee/DBManager.java index 37645ec008..a5092f29bd 100644 --- a/modules/dbsupport/src/main/java/org/jpos/ee/DBManager.java +++ b/modules/dbsupport/src/main/java/org/jpos/ee/DBManager.java @@ -21,8 +21,8 @@ import org.hibernate.query.criteria.internal.OrderImpl; import javax.persistence.NoResultException; -import javax.persistence.Query; import javax.persistence.criteria.*; +import org.hibernate.query.Query; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -37,6 +37,11 @@ public DBManager(DB db, Class clazz) { this.clazz = clazz; } + /** Convenience method */ + public T byId(Long id) { + return db.session().get(clazz, id); + } + public int getItemCount() { CriteriaBuilder criteriaBuilder = db.session().getCriteriaBuilder(); CriteriaQuery query = criteriaBuilder.createQuery(Long.class); @@ -65,7 +70,7 @@ public List getAll(int offset, int limit, Map orders) { query.where(predicates); query.select(root); query.orderBy(orderList); - Query queryImp = db.session().createQuery(query); + Query queryImp = db.session().createQuery(query); if (limit != -1) { queryImp.setMaxResults(limit); }