-->
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.  [ 3 posts ] 
Author Message
 Post subject: a different object with the same identifier value was alread
PostPosted: Mon Oct 03, 2005 5:13 am 
Beginner
Beginner

Joined: Thu Jun 10, 2004 6:52 am
Posts: 29
Hibernate version: 2.1.8

Mapping documents: classic parent/child bidirectional one to many inverse = true, Area(1) -> (*)Zone

I'm using Spring + hibernateTemplate

So what I do is I want to update a Zone. The zone is disconnected between requests, being stored in a session form bean. When I update the zone, I must specify the area it is in:

Area.addZone() method body:
getZones().add(zone)
zone.setArea(this);

At update form submission I do this:

Area area = getHibernateTemplate().get(Area.class, areaId);
area.addZone(zone);
getHibernateTemplate().update(zone);

Here I get: "a different object with the same identifier value was already associated with the session ... of class: Zone

Can somebody give me a hint how to do to avoid it. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 5:50 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
instead of update try doing a merge.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 5:57 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
sorry didn't see you were using spring. with hibernate 2.1.8

hibernate 3 has merge which solves this problem.


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

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.