Joined: Wed Mar 25, 2015 6:23 am Posts: 1
|
Table 1 : EmpData Emp_id Number(5); Amend_CNT Number(5) Address VARCHAR(100)
Here Primary Key is Emp_Id, Amend_CNT. now Child Table is Child Table : EmpContact Emp_id Number(5); Amend_CNT Number(5) Contact_No Number(10)
hibernate : public EmpContact() { private EmpData empData; private String address; }
in this table Emp_id and Amend_CNT is a foreign Key which reference of Table1:
code : EmpData emp = new EmpData(); emp.setEmpId(1); emp.setAmendCnt(1); emp.setAddress("Bangalore");
EmpContact cnt1 - new EmpContact() cnt1 .setEmpData(emp) cnt1.setContactNo(99999999); emp.getEmpContact().add(cnt1);
EmpContact cnt2 - new EmpContact() cnt2.setEmpData(emp) cnt2.setContactNo(00000000);
emp.getEmpContact().add(cnt2);
session.save(emp ); session.flush(); session.refresh(emp );
in the above code data get written in EmpData . but in the child table EmpContact data not written.
Please Help me to solve this problem
|
|