Hi, question 12: why is box D. "SELECT OBJECT(o) FROM Order o checked" ? Normally, this query means "finds all orders". I understand that it may also mean "orders with lineItems" because conceptually, what does mean an order without lineitems? Nothing interesting... But in the same book, p.418, we have also an example of one-to-many relationship between a Director(1) and Movies(n), and here, the query:
SELECT DISTINCT OBJECT (d) FROM DirectorSchema d WHERE d.movies IS EMPTY
makes apperently sense to the authors: "this query returns only those directors who have not madde any movies" or "Just show me the losers who haven't made any movies..." Can't we imagine also that it may exist "loser orders which haven't any lineitems?". More seriously, it seems that the relationship one-to-many doesn't necessary imply a conclusion about this kind of question. Because it tells us only about maximal cardinality and not minimal cardinality. So the relationship between a Director and movies may be of type (1,1) -> (0,n) whereas relationship between an order and lineitems would be rather of type (1,1) -> (1,n). Which means also that a Director without movies is conceptually conceivable whereas an Order without Lineitems is not. Which means also that query
SELECT DISTINCT OBJECT (d) (or (o)) FROM DirectorSchema d (or Order o)
doesn't mean exactly the same thing... Regards, Cyril.
SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
Hi Cyril: The way the question is worded, it can be inferred that it is possible in this case to have orders without line items, not that it makes sense. Therefore SELECT OBJECT(o) FROM Order o would return all orders with or without line items. The correct query should have a WHERE clause as follows: SELECT OBJECT(o) FROM Order o WHERE lineitems IS NOT EMPTY I recently posted to a thread discussing the same issue. You can find it at https://coderanch.com/t/158551/java-EJB-SCBCD/certification/EJBQL-HFE-page Hope this helps.
Keith Rosenfield<br />SCJP<br />SCWCD<br />SCBCD
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop