Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

HF Page434 Q. 12

 
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.
 
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.
 
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".
 
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.
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic