-->
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: StaleObjectStateException within same session
PostPosted: Mon Oct 06, 2008 1:20 pm 
Newbie

Joined: Tue Nov 16, 2004 6:35 pm
Posts: 6
Try to use StaleObjectStateException to prevent current modification. It worked however but broke my existing code.

I am doing two thing within one method, say

foo(params...){
...
//do a save, so as I can get the id to be used in anotherMethod()
save(ccCase);
//
anotherMethod(ccCase.getId());
...
}

The problem is within the anotherMethod() I am doing a findByExample() call.

Hibernate does a insert for ccCase, and within the anotherMethod, it does an update for ccCase again, which I am not quite sure why. So the StaleObjectStateException was thrown even this is really within the same method, not modified by another user. I understand if I comment the save() method, when the findByExample() was called within the anothrerMethod, hibernate will do the save as well, since hibernate will flush before query sometime. But I do need the save so I can get access to the id it generated.

What do I need to do the prevent this StaleObjectStateException from happening here?

Thanks,


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.