aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes cmp fetching values from two table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "cmp fetching values from two table" Watch "cmp fetching values from two table" New topic
Author

cmp fetching values from two table

alec stewart stewart
Ranch Hand

Joined: Dec 23, 2003
Posts: 71
hi friends
i want to know how can i fetch values from two related tables using cmp.like there are to tables employee and designation.employee table consist designation id. when i perform findall it returns all values from employee table including desig_id but i want to find the desigation name corresponding to designation id.
a small example will be of great help.
thanks :roll:
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
I doubt it's possible to use just 1 cmp to have data from two tables. One way is to create CMP based on updatable view (joining two tables) but depends on the DB.

The other way is to have 2 CMP and define relation ships or you can use ejbSelectXXX() method.
alec stewart stewart
Ranch Hand

Joined: Dec 23, 2003
Posts: 71
Purushothaman
can u please give me a simple example code on the second method that u r telling.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Alec,

You can also consider creating a view which joins the two tables and define a CMP for the view. Some servers like weblogic allows mappign an enity bean to more than one table.


Groovy
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
if Employee <--CMR (designation)--> Designation
then employee.getDesignation.getName() should get you the designation name , no ?
alec stewart stewart
Ranch Hand

Joined: Dec 23, 2003
Posts: 71
karthik guru
can u please help me by providing me with a small working example of the solution that you have mentioned.
thanks in advance
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cmp fetching values from two table