-->
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: Force a write ingnoring version check
PostPosted: Tue Apr 29, 2008 10:20 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 4:47 am
Posts: 25
Is there any way, to force a write of an object, which does not throw a stale object exception, thus overwriting the data table.

I have a dialog, which ops up during a stale object exception, and shows the user, the two states of the same object. their in-memory object, and the latest persistent object from the database.
The choice then, is to abandon their object, and refresh from the database, or to force an overwrite of the database, with their object.

But how do I stop another stale object exception from happening.
I've tried setting the version property of the in-memory object to that of the stored object, but an exception happens.

Any clues ?

Thanks


Top
 Profile  
 
 Post subject: Force a write ingnoring version check
PostPosted: Fri May 02, 2008 6:00 am 
Senior
Senior

Joined: Thu Jun 21, 2007 8:03 am
Posts: 127
Location: UK
Hi,

I suspect your best bet is to simply overwrite the properties of the most recently loaded object to avoid the stale object exception.

In addition, consider what would happen if you attempt to 'force' a write but, in the time taken for the user to confirm, yet another person has comitted further changes. I suspect the user would then be unaware that they have overwritten subsequent changes sine the first exception.

Regards,
Richard


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 6:27 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 4:47 am
Posts: 25
Good point.

Maybe I can lock the offending record in the table, when the first exception occurs - I need to investigate, and test the possibility of deadlocks etc.

It seems that 'persist' will do the trick for writing the object.

thanks for your advice.


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.