Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF Page434 Q. 12

 
Purvesh Vora
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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.
 
Kin Ng
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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.
 
David McDonagh
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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".
 
Sumitro Palit
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DISTINCT implies duplicates will be avoided - it can still return a collection of unique records staisfying the QL statement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic