Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

HFEJB - Chapter 7 - Page 428 - Q # 12 - CMP Question

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question # 12:
Given CMP beans CustomerBean,OrderBean and LineItemsBean with the following relationships:
CustomerBean (1) <->OrderBean(n)
OrderBean (1) <-> LineItemsBean(n)

The following answers have been marked as correct in Answers section.
Question: Which will return orders that have lineitems?

Choice B - Select Distinct Object(o) FROM Order o, IN(o.lineItems) li
Choice D - Select Distinct Object(o) FROM Order o where o.lineItems is not empty.

I feel that only choice D should be correct, as the question says "Which EJB-QL will return orders THAT HAVE LINE ITEMS?"

In choice B we donot check if the collection referred is empty or not.

Any suggestions would be valuable ?

Regards,
Aleena
 
Aleena Rehman
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any body help me out ?
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ale,
Hope you don't mind the name. The answers to that question
is B and D. Ok let look at it. The IN operator is used to return collections
when used in the From clause. In the Order bean class, there must be a method that returns a collection of lineItems like

public abstract Collection getLineItems();

So, when you select everything which the Order class represent, you are including the lineItems. But if you now want to restrict the query to a particular lineItem, you can now do that in the where clause.

Hope it helps.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic