• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please explain me following EJB-QL Query.....  RSS feed

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

Please explain me followin EJB-QL Query which is using finder method..
==============
<ejb-ql>SELECT MAX(l.lineItemId) FROM Account AS a, IN (a.accountLineItem) l WHERE l.accountId=?1</ejb-ql>
============


Please explain me ??
Also pls tell me wat is lineItemId, Account & accountLineItem Here???
Which one from above table names & Bean_interfaces names???
I have copied this query from a web page but can't understand it.

Please help me.

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

Every EJB-QL expression must have a SELECT (indicating what must be returned) and a FROM clause (indicating which beans are being worked with). The WHERE clause is optional.

This query
SELECT MAX(l.lineItemId) FROM Account AS a, IN (a.accountLineItem) l WHERE l.accountId=?1
says.

Select the max value of the lineItemId field (from the accountLineItem collection entries),
FROM the Account bean (which in this query will be known by the short format a) ,
IN the accountLineItem collection (which in this query will be known by the short format l)
WHERE the lineItems to be worked with must only be for the accountId that matches the supplied finder method parameter.


I might not have been clear about the IN section of the query above - it is used to identify that the query must look at all the items that exist in a collection in the bean.

The AS clause is used to assign a short name for the AbstractSchema name that can be used in the query besides the AbstractSchema name.


Chris
[ January 19, 2006: Message edited by: Chris Brat ]
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
?1 means the first argument in the method signature invoked by client( client means the component which invokes the entity EJB). ?2 stands for 2nd argument and so on
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,

I m still confused with "accountLineItem" in the above query. U told dat is is collection.
Whether is ts the name of Table in Databse???

Thanx..

Prash
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!