Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

what is wrong in following EJBQL??

Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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(

Where is the problem??
Please help me.
Thank you.
Posts: 17346
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic