Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ques about EJB-QL

 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A sample ques from a mock exam...

1 order may consists of many products.

Write the EJB-QL query to find all the products at the ABC store that have been involved in orders.

Well, I wrote :- select object(p) from Orders o, IN(o.products) p where o.storename="ABC"

The answer that was given was :-
Select object(p) from orders o,product p where p MEMBER OF o.products and o.storename="ABC"

Now, Is my answer correct... ???
AND
What's this answer that they have provided with "Member of ...."

[ August 17, 2004: Message edited by: Giju George ]
[ August 17, 2004: Message edited by: Giju George ]
 
Giju George
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys.. any answer !!!
 
Nitin Mehhta
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think both are correct. Member Of is also valid in EJB-QL...
it tests if a single valued entry is there in a collection-valued path expression.
 
Severin Stoeckli
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Giju wrote:
select object(p) from Orders o, IN(o.products) p where o.storename="ABC"
Now, Is my answer correct... ???


In my opinion, your answer is correct since the identification variables o and p are defined correct and the comparison is made with a single_valued_path_expression. The only thing that is wrong, as far as I know, is that you use double-quotes for the string literal.

However, an easier way of thinking about this problem is the following:

you'r relationsip is Orders(1)------(m)Products

that's the same as Products(m)------(1)Orders


Further, both "Products" and "Orders" must be abstract scheme names, since you must decribe their relationsip (or does anybody disagree?).


Therefore you could write:

select object(p) from products p where p.orders.storename='ABC'

this example corresponds to the second example in 11.3.1 of the spec (see also the relationsip diagram on page 221 that corresponds to all examples)

do you agree ?

What's this answer that they have provided with "Member of .

See spec 11.2.7.12

Severin
[ August 18, 2004: Message edited by: Severin St�ckli ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic