• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB QL - Joining two entities

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is the following query wrong:
SELECT s.name FROM Student s, Program p where s.subjectid=p.subjectId
The following thread gives the details: invalid ejb-ql

However, the following thread says it is possible to join two entities by specifying them in FROM clause: joining two entities in FROM clause

The same logic is explained in J2EE tutorial: J2ee tutorial

Please clarify which one is correct.

BTW, are there EJB-QL verifiers which can be used to verify our Queries apart from writing example applications and verifying ?
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While joining one to many or many to many CMR fields, you should use IN syntax. For joining by CMP fields you can use regular SQL like syntax.
Cheers.
 
Sankar Subbiramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. Where do you find more details / explanation about this ?
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome !!
HFEJB coverage is not bad. I have read HFEJB only so far but I have previous experience of SQL also which is very similar.

[ December 16, 2005: Message edited by: Devender Thareja ]
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sankar Subbiramaniam:
Thanks. Where do you find more details / explanation about this ?



On the same page, but a bit higher:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBQL4.html#73421
 
Sankar Subbiramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HFEJb mock exam Question 58 (Page 676), clearly tells that you can join two related entities in the notmal way.
(i.e)
Select Distinct Object(c)
From Customer c, Order o
Where c.custnum = o.custnum

The same query can be also written as

Select Distinct Object(c)
From Customer c, IN (c.orders) o
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic