Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where do we write EJB-QL in DD

 
shanthisri mocherla
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
can anyone please help me in this topic. I searched the EJB spec for this.but did not find the answer.
I know that we write EJB-QL queries in ejb-ql tag in DD,But where is it located?
So how the container looks for information in finder methods of home interface and select methods bean class when it comes across a ELB-QL query?


Thanks in advance

shanthisri
 
Mishra Anshu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have taken this reference from EJB cookbook, which may help you to understand the things.








Let�s examine a query method description from the deployment
descriptor more closely:



Each custom finder method should be described by a <query/> block in the
deployment descriptor for each bean. In the <query/> tag, you specify the method
name and its parameter types (in the order that they appear in the method).
Lastly, you specify the EJB-QL string that represents the entity bean query that the
method should execute to return an entity bean or beans to the EJB client.
An EJB-QL string resembles a JDBC prepared statement in that arguments are
represented by a question mark (?). However, in EJB-QL you also add a number
next to the ? that specifies which argument it represents (first, second, third, and
so forth). EJB-QL is not hard to use, but it also does not encompass as many features
as SQL. Examining our statements, you can see they have three parts:

1.The SELECT clause can return any EJB object, CMP, or CMR field. When
returning an EJB, the statement must use the OBJECT() operator to surround
the return type. If returning a field, you can simply state the field,
like SELECT a.symbol. In the SELECT part, you can also make use of the DISTINCT
keyword, as in SELECT DISTINCT OBJECT(a). This will cause each
returned value to be unique, with no duplicates.

2.The FROM clause allows you to select the scope to pull data from. For
instance, in our queries we are extracting data from the EquityBean EJBs.
The AS keyword lets you rename the bean with an identifier. The identifier
cannot be a name that is already used for an EJB name or abstract schema
name (and the identifier is not case sensitive).

3. The WHERE clause lets you drill down to specific data by setting up conditions.
The data returned from the statement must meet the conditions in
this clause. In our example, the lastTrade field of an EquityBean EJB should
be greater than our input parameter.
For more information on EJB-QL, go to Here

Hope, it helps

[ March 29, 2006: Message edited by: Mishra Anshu ]
[ March 29, 2006: Message edited by: Mishra Anshu ]
 
shanthisri mocherla
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mishra Anshu
Thank you very very much for your prompt reply and detailed explanation.
Now I understood the concept thoroughly.

Thanks
shanthisri
 
Mishra Anshu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic