You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by zhourui <zh...@zoneland.net> on 2015/07/01 15:29:50 UTC
groupBy only return first row of resultSet
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Tuple> cq = cb.createQuery(Tuple.class);
Root<Task> root = cq.from(Task.class);
Predicate p = cb.equal(root.get(Task_.person), person);
javax.persistence.criteria.Path<String> applicationNamePath =
root.get(Task_.applicationName);
Expression<Long> countPath = cb.count(applicationNamePath);
/*here is the problem*/
cq.multiselect(applicationNamePath,
countPath).where(p).groupBy(applicationNamePath);
for (Tuple o : em.createQuery(cq).getResultList()) {
WrapOutCountApplication wrap = new WrapOutCountApplication();
wrap.setApplicationName(o.get(applicationNamePath));
wrap.setCount(o.get(countPath));
list.add(wrap);
}
expect return mulit row,but it only return the first row.
is this a bug?
--
View this message in context: http://openjpa.208410.n2.nabble.com/groupBy-only-return-first-row-of-resultSet-tp7588359.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: groupBy only return first row of resultSet
Posted by zhourui <zh...@zoneland.net>.
with distributed slice.
version : openjpa apache-openjpa-2.4.1-20150701.074119-8-binary
--
View this message in context: http://openjpa.208410.n2.nabble.com/groupBy-only-return-first-row-of-resultSet-tp7588359p7588361.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: groupBy only return first row of resultSet
Posted by zhourui <zh...@zoneland.net>.
with the CriteriaBuilder.count() it only return the first row.
without CriteriaBuilder.count() can return mulit rows.
--
View this message in context: http://openjpa.208410.n2.nabble.com/groupBy-only-return-first-row-of-resultSet-tp7588359p7588363.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.