-->
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: ConstraintViolationException shouldn't invalidate session
PostPosted: Sat Mar 05, 2011 1:04 pm 
Newbie

Joined: Wed Apr 08, 2009 1:11 pm
Posts: 19
Hi,

I'm upset about the hibernate handling of ConstraintViolationException. It invalidates the session. I use TRANSACTION_READ_COMMITTED and want to avoid pessimistic locks as much as possible.

I have many cases of idempotent get/create for relationships, an example being a category path. For this example, the subpaths have parent/child relationships. I want to set a unique constraint on the db, such that only one parent/child relationship for those id pairs is allowed.

I have multiple threads that want to get/create the category path. It would seem logical that if a getter got null, then it could create the relationship it needed, catching ConstraintViolationException and getting again to get the same relationship that another thread committed. And continuing the session to get/create other parts of the subpath of the full category path.

However, Gavin King et alia didn't permit this design paradigm, and I am forced to use an optimistic get, and if I get null, then do a pessimistic lock.

When are the authors of Hibernate going to change this?

Andy


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.