Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

EJB QL - Joining two entities

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
And tomorrow is the circus! We can go to the circus! I love the circus! We can take this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic