• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

what is wrong in following EJBQL??

Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing My application using CMP EJB2.1 Spec.
In one of my entity bean I am writing followinf EJB QL in my EJB-SELECT Query:-
SELECT COUNT(userid) FROM OrderMaster as o GROUP BY o.userid

But when I am deploying under my app server (JBOSS4.0.3), I am getting following error:-
15:05:27,328 INFO [STDOUT] javax.ejb.FinderException: Error compiling ejbql: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "GROUP" at line 1, column 44.
Was expecting one of:
"," ...

15:05:27,328 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.execute(JDBCDynamicQLQuery.java:101)

Where is the problem??
Please help me.
Thank you.
Posts: 17346
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well just basic querying is that if you have an aggregate you don't group by that aggregate field. You only GROUP BY on the fields that aren't aggregates.

For example

Select a, b, COUNT(c) from atable GROUP BY a, b

In the above a and b have to have a group by, but "c" which is inside the aggregate function COUNT should not be.

Remove the GROUP BY in your query and it should work. Also in your COUNT prefix userid with "o." your object alias.

To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic