Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB QL & CMR

 
Pally Gharmount
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to write a customised finder method for my CMP EJB. The EJB has a one to many relationship with another bean.

How can i write EJB-QL that will return results matching criteria in both beans..this is how i would do it in oracle....

SELECT *
FROM BGS.WELL_DATA A, BGS.SURF_DEPTHS B
WHERE A.WID=B.WID
AND A.WID=4
AND B.SOURCE='SH'
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SELECT *
FROM BGS.WELL_DATA A, BGS.SURF_DEPTHS B
WHERE A.WID=B.WID
AND A.WID=4
AND B.SOURCE='SH'


It would be like this :

assuming its one to many relationship between tables WELL_DATA and SURF_DEPTHS and unidirectional from WELL_DATA to SURF_DEPTHS. In WELL_DATA CMP, we have a cmr field - surfdepths.

SELECT OBJECT(o) FROM schemaNameInWell_DataCMP o IN (o.surfdepths) y WHERE o.wid=?1 AND y.source=?2

where wid and source are cmp fields in both CMPs and finder method signature can be like :

findBySomeMethodName(Integer wid, String source)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic