-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HibernateTemplate merge() problem
PostPosted: Fri Dec 18, 2009 12:16 pm 
Newbie

Joined: Wed Nov 11, 2009 6:41 am
Posts: 7
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.