Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

ques about EJB-QL

 
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 !!!
 
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.
 
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 ]
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic