posted 17 years ago
12 - Given CMP beans CustomerBean, OrderBean and LineItemsBean with the following relationships:
CustomerBean (1) <--> OrderBean(0..n)
OrderBean (a) <--> LineItemsBean (0..n)
Which will return all orders that ***HAVE** items?
A - SELECT DISTINCT o FROM Order o, IN (o.lineItems) li --> OK, wrong - imcomplete query.
B - SELECT DISTINCT OBJECT (o) FROM Order o, IN (o.lineItems) li
C - SELECT OBJECT (o) FROM Order o WHERE o.lineItems = 0 --> o.lineItems is a collection and therefore cannot be compared to a int value.
D - SELECT OBJECT (o) FROM Order o WHERE o.lineItems IS NOT EMPTY. --> OK, that's even makes sense.
My question is:
B - The question statement says : "orders that ***HAVE** items" ...
- Why is the option B enough since there is no consistence (WHERE clause, IS NOT EMPTY, something) in order to check if there are valid collection elements ??
Tks!!
SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669