• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFE Page 428 - Q12 : EJB-QL (one to many relationship)

 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
On page 428, Q 12 says-


Given CMP bean customerBean, orderbean, lineitembean with following relationship...
customerbean (1)<--> orderbean(n)
orderbean (1)<--> lineitembean(n)
Which will return all orders that have line items ?


the correct ansers are -
B. SELECT DISTINCT OBJECT(o) FROM order o IN (o.lineitems)li
D. SELECT DISTINCT OBJECT(o) FROM order o
I feel these answers are wrong. The questions says that orders that have line items. so the query should be...
SELECT DISTINCT OBJECT(o) FROM order o where o.lineitems IS NOT EMPTY
Same type of query is written on page 418, where director has many movies and you want to select all directors having movies associated.
Can someone explain the above metioned answers in HFE?
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right. I submitted this error to the errata list and its unconfirmed from Kathy. Check the link at the bottom (they are sorted by Pg numbers see Pg 434)
http://www.oreilly.com/catalog/hfjejb/errata/hfjejb.unconfirmed
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the correct ansers are -
B. SELECT DISTINCT OBJECT(o) FROM order o IN (o.lineitems)li
D. SELECT DISTINCT OBJECT(o) FROM order o
I feel these answers are wrong. The questions says that orders that have line items. so the query should be...
SELECT DISTINCT OBJECT(o) FROM order o where o.lineitems IS NOT EMPTY


B is equivlent to your ql.
here is quote from spec on page 224.

An identification variable designates an instance of an entity bean abstract schema type or an element of
a collection of entity bean abstract schema types instances. Identification variables are existentially
quantified in an EJB QL query.


I think IN(o.lineItems)l means there exists l in 0.lineIems.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic