-->
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: Update problems - because of HibernateUtil?
PostPosted: Mon Jul 12, 2004 11:47 am 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
I am running into problems updating an object

2004-07-12 16:39:39,923 ERROR SchedulesUpdAction.doWork(SchedulesUpdAction.java:108) : a different object with the same identifier value was already associated with the session: 402, of class: com.qas.newmedia.intranet.iq.dto.schedules.DataAcquisitionSchedule

This is where I have used HibernateUtil which only ever creates one session as far as I can see and uses an internal ThreadLocal to manage it. Therefore because I use load my object out of this session and later return to save it I get this error.

My question is should I not use HibernateUtil? Should I just create new sessions each time I need to do something? Or should I reload my object first, overwrite the relevant fields with the updated values and then resave?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 12:02 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
When asking questions, give at least:
the Hibernate version
your mapping documents
the Java code between sessionFactory.openSession() and session.close()
the full stack trace of any exception that occurs
the name and version of the database you are using
a debug level Hibernate log excerpt is also appreciated

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 12, 2004 12:11 pm 
Senior
Senior

Joined: Fri Jun 18, 2004 10:17 am
Posts: 140
I have managed to get it working by first loading the object, then setting the values with the new ones and then calling update. Seems to be a round-about way of doing it. I would have thought if I populated an object with all the required values (including id) and sent that to session.save it should have done it, but it complained it had already loaded such an object. I checked HibernateUtil and it does actually close sessions so I do not know why it thinks it still has a reference.

oh well.


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.