-->
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: NonUniqueObjectException - looking for a better solution
PostPosted: Wed Jun 08, 2011 8:43 am 
Newbie

Joined: Fri Jun 03, 2011 7:57 pm
Posts: 2
I have a scenario where my service layer gets called to do an update supplying a complete VO.
In some cases, depending on what values have changed I need to drive some processing.
So, my code retrieves the original VO from the database and does the comparisons.

Once all the attendant processing has been done, the code continues with the update.
However, the update fails with the exception
Code:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.usaa.wrkmgr.effort.publicapi.valueobject.EffortVO#211]
   at org.hibernate.engine.StatefulPersistenceContext.checkUniqueness(StatefulPersistenceContext.java:613)


I can work around this by using an EJB call (with an associated new transaction) around the retrieval of the original data. I don't like this solution because its unneccesarily complex and I dont want the overhead of a new transaction every time I retrieve data.

Essentially, I need the retrieval of the original object to be a 'read only'. I considered a 'getForRead' style method with the DAO but I don't want my service layer to have to be aware of the peculiarities of my persistence layer.

Can anyone suggest a different way to solve this issue?


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.