HI Forumists,
I am facing a problem with merge() when it is used in associationally related objects.
I have a 2 tables as [EMP, Personal_Data]
here b/w the two tables id is the foreigh key.
I have a one-to-one relation ship b/w Emp to personal_data.
In the personal_data(id) is a foreigh key to Emp.
But i am getting Emp Obj and i am inserting the Emp object as
getHibernateTemplate().merge(empobj);
Code:
so lets assume my emp obj contains values like
Emp empobj=new Emp();
empobj.setDep("Eng");
Personal p=new Personal();
p.setName("hibernate");
p.setLname("forum");
empobj.setPersonal(p);
It is storing valus into the Data Base tables as
Code:
Personal_data
---------------
id name lname
.... ........ .........
1 Null Null
2 hibernate forum
Emp
-----
id Dep
... ......
1 Eng
But when i use getHibernateTemplate().save(empobj) it is storing fine
But
why i getting problem when i useing merge()?Could u pleasue suggest something regarding this.