Page 434 HF EJB. Can someone explain to me why answer B is correct?Which part of the query ensures that the orders returned have line items?Does the IN(o.lineItems) li just mean "let li represent an individual line item in the Order Collection?
the variables. For example: SELECT OBJECT(o) FROM Order AS o, Customer AS c The above query finds all orders if and only if there are any customers (which do not need to be related to the Order objects). Even though we aren't using the variable c anywhere else, we are still excluding orders if there are no cus� tomers. By declaring a variable, you are constraining the domain of the query. This is similar to the following SQL statement that returns all orders so long as there are one or more records in the Customer table: SELECT o.* FROM Order o, Customer c
As the first line states , The above query finds all orders if and only if there are any customers (which do not need to be related to the Order objects)
This is similar to the following SQL Statement all orders so long as there are one or more records in the Customers Table: SELECT o.* FROM Order o, Customer c
And in which way is this explanation supposed to be helpful? Thats like saying multiplying any number by zero results in zero. In fact that query is pretty much useless as it produces a cartesian product. To make my point here are some examples from the pointbase database that comes with the Sun RI 1.4 J2EE server:
Originally posted by jeff mutonho: " Customer c " introduces the condition that the results will depend on the existence of "one or more records in the Customers Table"
I'm objecting to the book presenting it as a special case. In SQL it is understood that if you don't specify a join condition the result will be the cartesian product of the (two, three, four,...) tables - which means every row "will be joined" with every other row. So if any one table contains zero rows - the result has no rows - big surprise. :roll:
The passage in the book (in this context) is silent on the fact that
will produce a cartesian product (see EJB Spec 11.3.5 p.238). Example: If there are 3 orders and 5 customers, that query will present each of the three orders to you five times. Once you understand that it produces a cartesian product the behaviour they are pointing out is no longer "surprising". Instead they make it look like a special case just to avoid having to explain what a cartesian product is.
you indicate that you wish to use the defined CMR between customer and order "as join condition", i.e.:
[ November 02, 2005: Message edited by: Peer Reynders ]