-->
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: Different object, same identifier, same session.
PostPosted: Wed May 04, 2011 1:25 pm 
Newbie

Joined: Mon May 02, 2011 3:42 pm
Posts: 3
I keep getting this exception and was confused. Before every test unit I'm grabbing a new session, and at the end of every session I'm always doing a rollback. I do not commit to the database. I was wondering why I would be getting this exception if I'm doing a rollback.

I am running 3 tests back to back in the same jvm(batch mode) for speed, but have found myself getting a lot of these exceptions.
I was wondering how I should be handling this exception, or what I should be doing to prevent this exception?
Thanks,
Code:
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.example.Employee#setName=[Bobby]]
   at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:638)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:305)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:246)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:112)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
   at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:685)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:677)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:673)


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.