Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

questions in HFE!

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, guys.
i got some questions in HFE.

No 12 on page 434 of HFE,it's about the EJB QL.
the question is
-----------------
Given CMP beans CustomerBean, OrderBean, and LineItemsBean with the following relations;

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

which will return all orders that have line items?
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 answer is b, d. but i think there is no answer.
and a,c is incorrect and i can know why.
but b,d also there is some problem as i think.
on B, there is no 'where' clause, so the result is all order objects(no duplicate).
on D is as same reason to b.but could be duplicated.

does anybody know?
 
cowbird
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

First of all, you need ALL orders that have lineitems. Orders with lineitems are a subset of all orders in the whole universe (database), so if you get ALL the orders there are, that will include all those having lineitems. That's why answer D is correct. You will never get duplicate orders, because of the DISTINCT keyword...

For answer B, the part "IN(o.lineItems) li" in the from clause makes the query look through each of the lineitems of each order. It lets "li" represent the Lineitem type instead of the collection type. So that EJB-QL returns only the orders that have lineitems.
 
youngwoo seo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx Jef....
 
I'm doing laundry! Look how clean this tiny ad is:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic