• 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 ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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
Hi,
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:
<EOF>
"," ...

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.
Pras
 
ranger
Posts: 17347
11
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.

Mark
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic