| Author |
Foriegn key mapping
|
sammeta Phanikumar
Ranch Hand
Joined: Oct 25, 2007
Posts: 81
|
|
Hi,
I have two tables as below.
Table Employee(
Employee_Id: Integer(11)
Employee_Name: Varchar(22)
)
Table Employee_Address(
Emp_Id: Integer(11) FK -> Employee
City: Varchar2(30)
Country:Varchar2(20)
)
All I want When ever a record is entered in Employee_Address, That record must have a mapping in Employee(Employee_Id) table.
I went through many articles on this.. many of them suggested that... in Employee .java should contain an object and setters/getters for Employee_Address. I dint understand this. Because if I do like this...I need to fill Employee_Address object to enter any record in Employee table.
I want Employee record to be entered with out any Employee_Address details. But to enter a record into Employee_Address must have a record in Employee.
Please clear me on this.
Thanks,
Phani
|
SCJP 5, SCWCD 5, SCDJWS 5
|
 |
sammeta Phanikumar
Ranch Hand
Joined: Oct 25, 2007
Posts: 81
|
|
Please help me any one.
PHani
|
 |
Larry Frissell
Ranch Hand
Joined: May 16, 2008
Posts: 82
|
|
|
I believe you want to use a one-to-one mapping relationship. See this link for an example with employee name and address.
|
 |
sammeta Phanikumar
Ranch Hand
Joined: Oct 25, 2007
Posts: 81
|
|
Thanks Larry for your reply,
But in this example if I want to enter a record only in Employee table then i have to setAddress with an Address object. this i do not want.
I just want work with Employee independently. But a record in Address must a have reference in Employee table.
Please help me in this...
Phani
|
 |
 |
|
|
subject: Foriegn key mapping
|
|
|