-->
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.  [ 2 posts ] 
Author Message
 Post subject: Unique columns, Race conditions and Friendly Error
PostPosted: Sun Mar 06, 2005 3:26 pm 
Newbie

Joined: Sun Mar 06, 2005 5:41 am
Posts: 13
Hello,

I am fairly new to hibernate, I have only used it to do simple things so far.
My scenario is this: I will have a table of users, the user.Name property is a unique column. What strategy should i take to ensure that there isnt a violation of the unique constraint and also tell the user that the name was already taken. I can catch DataIntegrityException in spring, but that does not tell me which column(s) was the culprit, neither does hibernate without having to do some regexp trickery with exception.getMessage();

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 06, 2005 3:44 pm 
Newbie

Joined: Sat Jan 29, 2005 7:09 am
Posts: 11
I was about to raise a new topic, but what I would like to achieve is the same as you zegloman.

I envisaged using the Hibernate mapping information to determine whether a given column has a unique index before saving data. This way, I hope to avoid unique constraint violations by running a Criteria query before saving (within the same transaction of course).

But does anyone know where in the Hibernate API we can get this information??

Thanks,

Doug.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.