Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Extracting a count query from a read query

On Wed, Sep 21, 2011 at 10:17 AM, James Sutherland <jamesssss@xxxxxxxxx> wrote:
It may work for simple queries, but for more complex ones you may be better
off removing the clause and replacing it with a count.  

Ugh; so parse the JPQL reliably and remove everything between the SELECT and the FROM?  Yuck.
 
But probably pretty difficult to do for any possible query.

You got that right.  :-)
 
Log an enhancement request to have a getCount() method added to JpaQuery to automate returning the count for a query.

Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=358436

Hope that gets implemented; that would make lots of people happy.  Most UIs need this in order to implement infinite scrolling or paging.  Frankly, I'd like to see it become part of the JPA standard somehow; perhaps an operation on EntityManager?

public long getCount(Query q);

Best,
Laird
 
--
http://about.me/lairdnelson


Back to the top