File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cmp fetching values from two table

 
alec stewart stewart
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Purushothaman
can u please give me a simple example code on the second method that u r telling.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if Employee <--CMR (designation)--> Designation
then employee.getDesignation.getName() should get you the designation name , no ?
 
alec stewart stewart
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic