• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

ques about EJB-QL

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys.. any answer !!!
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic