• 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

HF Page434 Q. 12

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,
The Q.12 is
Given CMP beans CustomerBean, OrderBean and LineItemsBean with the following relationships:

CustomerBean (1) <--> OrderBean (n)
OrderBean(1) <--> LineItemsBean(n)

Which will return all orders that have line items? (Choose all that apply.)
A. SELECT DISTINCT o FROM Order o, IN (o.lineItems)li
B. SELECT DISTINCT OBJECT(O) FROM Order o, IN(o.lineItems) li
C. SELECT OBJECT(o) FROM Order o WHERE o.lineItems = 0
D. SELECT OBJECT(o) FROM Order o

The correct answers are listed as B and D.

B is fine. But how the answer D is TRUE?

Could anybody please explain?
Thanks.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it's the wording of the question.
It says "will return all orders that have line items" (didn't say only).

The set "all orders that have line items" is definitely
a subset of the resultset of Query D, which contains all orders.
That's why D is correct too.

This is what I think.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually can someone explain why Option B is correct? My naive understanding that the syntax DISTINCT would only return one object and not a collection i.e. "all orders with lineitems".
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DISTINCT implies duplicates will be avoided - it can still return a collection of unique records staisfying the QL statement.
reply
    Bookmark Topic Watch Topic
  • New Topic