Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP 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
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

EJB-QL Query

 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given:
CustomerBean (1) <--> OrderBean (n)
OrderBean <--> LineItemBean (n)

In order to return a set of customers that have orders, can I confirm that the following two queries are correct. One thing that I'd like to be 100% sure is that in (a), if c.orders is empty, then no customer will be returned.

(a)
SELECT DISTINCT OBJECT (c)
FROM Customer c, IN (c.orders) o

(b)
SELECT DISTINCT OBJECT (c)
FROM Customer c
WHERE c.orders IS NOT EMPTY
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both are right
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roger,

Both the queries are correct and will return the same result. Refering to the IN clause in HF EJB, for (a) query, it has been defined that return all the customers who has some orders which is same as (b) which says return all the customers whos corresponding orders are non-empty.

Hope this will clarify your doubt.

Thanks
Lalit
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the confirmation, guys, though I still struggled with the EJB-QL in the exam today . But I did pass the exam .
[ June 01, 2004: Message edited by: Roger Chung-Wee ]
 
Everyone is a villain in someone else's story. Especially this devious tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic