Derived Queries

View: New views
2 Messages — Rating Filter:   Alert me  

Derived Queries

by Jeremiah Johnson-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to write a JPQL Query that counts the number of records in
a set. I tried using a ReportQuery (with the origional JPQL) but that
has problems if the JPQL query is already returning results. The
ReportQuery tries to add the count to the results list which causes an
sql error because the other results in the origional query are not
grouped. I think I need to have something like:

select count (obj) from (select obj2 from table obj2) obj

But that does not work. Is there a way I can suppress the columns in
the ReportQuery (made from a JPQL query) that are not grouped or  is
there some way to make the JPQL above work?

--
Jeremiah Johnson
Kunz Leigh & Associates
Phone: 517-488-7393
_______________________________________________
eclipselink-users mailing list
eclipselink-users@...
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Re: Derived Queries

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Not sure I understand, why not just use,

"Select count(object) from table object"

Perhaps include the code for the query you tried, and the SQL/error you got.


Jeremiah Johnson-7 wrote:
I'm trying to write a JPQL Query that counts the number of records in
a set. I tried using a ReportQuery (with the origional JPQL) but that
has problems if the JPQL query is already returning results. The
ReportQuery tries to add the count to the results list which causes an
sql error because the other results in the origional query are not
grouped. I think I need to have something like:

select count (obj) from (select obj2 from table obj2) obj

But that does not work. Is there a way I can suppress the columns in
the ReportQuery (made from a JPQL query) that are not grouped or  is
there some way to make the JPQL above work?

--
Jeremiah Johnson
Kunz Leigh & Associates
Phone: 517-488-7393