-->
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: Observing StaleObjectStateException
PostPosted: Fri Oct 24, 2003 11:52 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 4:17 pm
Posts: 27
Location: California, USA
My application needs to take action whenever optimistic concurrency control fails (for example, whenever a database change fails because the version of an affected row is different from the version last read). As I understand it, whenever Hibernate detects this it throws a StaleObjectStateException, which is helpful. But it's a nuisance that StaleObjectStateException might propagate from any one of many Hibernate methods.

I'd like one method in my application to be called whenever Hibernate throws a StaleObjectStateException. Can you recommend a way to implement that? I'd be willing to make Hibernate 'observable' (in the Design Patterns sense), and interested in the Hibernate developers' opinion of that idea.

Currently I'm wrapping a java.lang.reflect.Proxy around every Hibernate Session, with an InvocationHandler that catches StaleObjectStateException. And I also have a similar exception handler where I call UserTransaction.commit. But I worry that these aren't sufficient, or that I can't afford the performance penalty of a Proxy.

Theoretically all my exception handlers could catch StaleObjectStateException and respond as desired. But in practice there are many such exception handlers, so that would be too much code to write and maintain.

P.S. In case you're curious, I intend to respond to StaleObjectStateException by evicting stale entries from the global cache. My application can obtain a summary of recent database changes and use it to identify stale cache entries, but the algorithm for doing so has a fairly high fixed cost, so I don't want to do it frequently unless optimistic concurrency control fails.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 24, 2003 11:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is a good idea. Please submit a feature request to JIRA.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 27, 2003 1:47 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 4:17 pm
Posts: 27
Location: California, USA
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-426


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.