• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

SELECT + CMR field

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
HFE p.406 tells us that

you can't use dot notation to return a CMR field, as the SELECT type


(It means it's only allowed to use it in the WHERE clause.
But in the spec, p.233, we can see the following query, considered as valid:
where lineItems, as far as I understand, stand for CMR.
So who is right?
Thanks for your help,
Cyril
[ March 08, 2004: Message edited by: cyril vidal ]
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I looked at page 233 of the EJB 2.0 final release spec. And the query that you showed was given as an example of INVALID EJBQL query.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the mentioned query is an invalid query only if the expected result is a collection.
- Walk Rustin
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Hmm, looks odd, I've downloaded the spec at work (ejb-2_0-fr2-spec.pdf), and I don't recognize exactly what i've seen at home (i've downloaded this version of ejb 2.0 spec one month ago).
Anyway, in this version, we can see

considered as a valid query.
With product being a CMR in lineitem entity.
So, may we use or not dot notation with CMR fiels in SELECT clause?
Thanks for your help,
Regards,
Cyril.
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have now the answer to my question.
HFE is wrong in writing that you can't use . with CMR fields.
It's absolutely allowed!
Why this note in p.406?
To my sense, you may return CMR reference object or CMP fields of related entities.
Cyril.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry i am late to the game. i was wondering about this as well. I assume that you would be forced to return the entire component interface and then call a getter on the CMR field (similar to the getMovieDirectorName() method on page 397 of the HFEJB book)
I then ran across this in the EJB spec -- section 11.2.8
Because finder methods cannot return arbitrary types, the SELECT clause of an EJB QL query defined for a finder method must always correspond to the abstract schema type of the entity bean for which the finder method is defined. In contrast, the SELECT clause of a query defined for a select method can return the abstract schema types of other entity beans or the values of cmp-fields.
Does this mean that the note on page 406 relates to EJB-QL for finder methods. While select methods could return an abstract schema type for another entity bean?
Carlos
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cyril,
It doesnt look like product, in the following query is a CMR field .
----------------------
SELECT l.product FROM Order AS o, IN(o.lineItems) l
------------------
Though the spec says that product is a CMR field on page 221 , in the example it doesnt look like one. As far as my understanding goes , if u return a beans component interface or a collection of such in the ejbSelect methods , u should have used Object as follows.
------------
SELECT Object(l.product) FROM Order AS o, IN(o.lineItems) l
----------------
please guys , correct me if iam wrong .
 
Ramakrishna Allam
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even that looks wrong . As the spec on page232 says that,"The SELECT clause must not use the OBJECT operator to qualify path expressions."
So ,
---------------
select Object(l.product) from Order o , IN (o.lineItems) l
-----------------
is also not valid . So , Its true that Kathys book is right . On page 406 , she says that select clause cant be used to return CMR fields.(because CMRfiled is an entity bean by itself , u have to use Object to return that . and the page 232 of the spec says that slect clause must not use OBJECT operator to qualify path expressions .ie since ,l.product is a path expression , we cant use OBJECT to qualify that for select clause).
Any thing went wrong in my explonation ?
Looks like , though EJB-QL is a small chapter and concept , there are around 5 questions in the exam . So , better prepare well for that and put more questions on the forum .
Ramakrishna R Allam ,
SCJP-95% , SCWCD-96%
 
Ramakrishna Allam
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the same can be achieved using the following query
SELECT OBJECT(p) FROM Order o , IN(o.lineItems) l , Product p
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic