[jboss-user] [JBoss Seam] - Re: count(*) and group by

christian.bauer@jboss.com do-not-reply at jboss.com
Tue Jul 24 20:32:58 EDT 2007


Finally, there _is_ a portable trick for retrieving the total number of rows a query would return:


  | ScrollableResults resultCountCursor = session.createQuery(q).scroll();
  | resultCountCursor.last();
  | long count = resultCountCursor.getRowNumber() + 1
  | resultCountCursor.close();
  | 
  | // Now do a q.llist() to retrieve the result
  | 

The problem here is that the crap JDBC drivers of certain databases (MySQL) do retrieve the resultset of server-side cursors to the client, which would usually result in an OOME - especially if the resultset is large and you actually want to paginate through it.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4067237#4067237

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4067237



More information about the jboss-user mailing list