Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] count rows of reportQuery without returning entire query.

Using sub-queries in the from clause is not currently supported.  Please log
an enhancement request for this.  You should be able to use a native SQL
query in the mean time.



redmondcs wrote:
> 
> I'm having trouble getting Eclipselink to perform a "select count(*) from
> (subQuery)"
> 
> I run the subquery separately with firstResult/MaxRows qualifiers to limit
> the returned results to say a window of 20 rows for pagination.  The
> subQuery happens to be a ReportQuery using a group by to generate summary
> information.  The report query returns 4 of 12 columns from the entity.  I
> would like a count of the entire result set for the reportQuery but
> EclipseLink is is not working properly.
> 
> Using an addCount() just adds an addition count(*) column to the query
> (now 5 columns) and counts what was grouped.
> 
> Creating another ReportQuery with an addCount("COUNT",
> countBuilder.subQuery(reportQuery), Long.class)
> generates the closest SQL "SELECT COUNT((SELECT ... FROM SOMETABLE T1
> GROUP BY ... ) FROM SOMETABLE  T0" but it is still invalid.
> 
> How can I get "SELECT COUNT(*) FROM (SELECT ... FROM SOMETABLE T0 GROUP
> BY)" without resorting to reading the entire result set and windowing the
> results myself.
> 
> I usually use a ReadAllQuery which is object based and can do the count of
> the result set without retrieving all the results but you cannot group
> with this query type.
> 
> Anyone figure out how to do this?
> 
> If not, this would make a nice extension.  I.E. a ReportQueryCount which
> takes a ReportQuery as a constructor and will generate the "select
> count(*) from (subQuery)" statement.
> 
> Thanks in advance.
> 
> Sean
> 
>  
> 


-----
---
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 
-- 
View this message in context: http://www.nabble.com/count-rows-of-reportQuery-without-returning-entire-query.-tp22661931p22663126.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top