-----Original Message-----
From: A mailing list for Enterprise JavaBeans development [mailto:[EMAIL PROTECTED]]On Behalf Of Sairam.T.D.G , STC Chennai
Sent: Friday, August 17, 2001 4:40 AM
To: [EMAIL PROTECTED]
Subject: EnityBeans with Pk and Fk
Hi,
I am having two table emp, dept. Dept is a parent table and emp is a child table with deptno as common field.
i am having corresponding entity beans
In the session bean ie controller class,
If i want to insert records into the database
I think there r two ways to use the primarykey-foreign key relationship
1. creating both objects in the session bean and call the appropriate methods
2. create dept object, i am planning to keep addEmp() method in it, in this method i will create emp object from remote interface and add it.I think second one is better in this way, encapsulation ie hiding the information about emp is achieved
plz send ur commets
SaiRamTDG
HCL Technologies Ltd
Title: EnityBeans with Pk and Fk
There are many ways to do what you want one of them
is:
Establish a many to 1 relationship between Emp and Dept, with Emp having
a <cmr-field> called dept which would force your to write setDept(Dept
dept) and Dept getDept() in your Emp bean.
Using
this method you can say: emp.setDept(dept) to put an employee into a
department. You can also say emp.getDept() to find out what department
employee belongs to. You can also implement Collection
Dept.getEmployees() thru EmployeeHome.findByDept(Dept dept)
function.
-AP_
- EnityBeans with Pk and Fk Sairam.T.D.G , STC Chennai
- Alex Paransky
