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

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.  But probably pretty
difficult to do for any possible query.

Log an enhancement request to have a getCount() method added to JpaQuery to
automate returning the count for a query.



ljnelson wrote:
> 
> This is in the context of JPA.
> 
> If I have some arbitrary JPQL query that starts like this:
> 
> SELECT <clause> FROM <arbitrary rest of query>
> 
> If I wrap the <clause> in COUNT(), will that return me the number of
> objects
> that match the query?
> 
> I am looking for an automated way to turn a generic SELECT query in JPQL
> into an "equivalent" COUNT query.  I am not sure if this is possible.
> 
> Best,
> Laird
> 
> -- 
> http://about.me/lairdnelson
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/Extracting-a-count-query-from-a-read-query-tp32498278p32503749.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top