on 08-23-2006 12:56 PM
Hi all,
I have one doubt while writing EJB's. I wrote one EJB project containing 2 EntityBeans named FirstEntityBean and SecondEntityBean. FirstEntityBean mapped to Table1 and SecondEntityBean mapped to the Table2 in the Database. There is a field named "LINKFIELD" in both the Tables which will link both the tables.
Now i want to retrieve some rows from both the tables based on the LINKFIELD. So for this i need to write a query using the JOINS in the EJB QL. I wrote the EJB QL in the finder Method of FirstEntityBean. But the return of the finder Method is FirstEntityBean. And i was unable to return the fields which are in the SecondEntityBean. How can i return these fields from the FirstEntityBean finder method. Is there any way for this?
Is Relations Concept is helpful for this requirement?
Thanks in advance,
RAMU.
Hi VJ,
Yes, Container-Managed-Relationship field have a pair of abstract getter and setter for it, return a reference or a Collection (or Set) to another entity bean.
For example, if there is a Movie Bean and Director Bean. One Movie bean can have only one director, but a director can have zero or many movie beans.
example of EJB-QL is as below:
SELECT m.title FROM MovieSchema m WHERE m.director.directorID=?1
Also, u need to configure <ejb-relation> tag for ejb-relationship-role, multiplicity, relationship-role-source, cmr-field and cascade-delete.
Hope this can help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.