Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write following SQL query in EJB QL????

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am developing a bean for which I want to write A EJB QL which Corresponds to following SQL Query:-
"Select max(employeeid) from employeemaster"

How should I write that???

I tried it using following:-
"SELECT MAX(employeeid) FROM employeemaster"

But it gives me error during deployment of bean.

Pls help me
Thanx in Advance,

Prash
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Prash,

Please give more information like the error message that you get.

Chris
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
It is giving Error like:
=========
17:01:36,968 INFO [STDOUT] org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "employeemaster" at line 1, column 25.
Was expecting one of:
"IN" ...
<ABSTRACT_SCHEMA> ...

17:01:36,968 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.ejbql.EJBQLParser.generateParseException(EJBQLParser.java:4284)
17:01:36,968 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.ejbql.EJBQLParser.jj_consume_token(EJBQLParser.java:4161)
17:01:36,968 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.ejbql.EJBQLParser.IdentificationVariableDeclaration(EJBQLParser.java:345)
17:01:36,968 INFO [STDOUT] at org.jboss.ejb.plugins.cmp.ejbql.EJBQLParser.FromClause(EJBQLParser.java:296)
...................
====================

I don't know where I m wrong. PLs help me.
Thanx,
Prash
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prash,

Your problem is because you are not using the correct syntax to look at fields of objects that exist in collections (one-to-many relationships within beans).

Read the J2EE tutorial on the SUN Java website and focus specifically on how the IN clause is used with regards to collections and relationships


Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!