-->
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: ConstraintValidationException wrapped in PersistenceExceptio
PostPosted: Thu Aug 05, 2010 8:36 am 
Newbie

Joined: Fri Jun 04, 2010 8:57 pm
Posts: 19
I was getting a feel of Hibernate Validator http://www.hibernate.org/subprojects/validator.html and its integration with the JPA (also provided by Hibernate). I was expecting ConstraintValidationException to be thrown separately (so that it can be handled separately), but it seems that the exception is wrapped inside the PersistenceException. I am a little confused as to the reason for this behavior. Also, what would be the best way to handle the ConstraintViolationException and present the user with the customized messages. Here is the environment that I am using

Java Swing (J2SE 6)
Hibernate JPA (sub set of full Hibernate)
MYSQL database.

regards,
Nirvan.


Top
 Profile  
 
 Post subject: Re: ConstraintValidationException wrapped in PersistenceExceptio
PostPosted: Tue Aug 10, 2010 5:10 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

can you post your code? I don't think that the ConstraintValidationException should be wrapped. There is also a unit test in Hibernate which shows that a ConstraintValidationException is thrown directly - see here.

Regarding the handling - ConstraintValidationException contains a method called getConstraintViolations which you can use to access the actual validation errors. From the errors you get access to the validation error messages. How you are going to display them is up to you.

--Hardy


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.