-->
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: How to handle invalid constraint annotations
PostPosted: Thu Jan 22, 2009 2:17 pm 
Newbie

Joined: Sun Mar 30, 2008 12:19 am
Posts: 15
I was wondering if and how an annotation with invalid data should be handled, for example

@Length(min=10, max=4)

Currently, Contstraint isn't defined to let any checked exceptions be thrown. Which of the following are appropriate response(s) for a Constraint implementation in this case?

1. RuntimeException in initialize(...)
2. RuntimeException in isValid(...)
3. isValid always returns false, placing a message in the ConstraintContext indicating the constraint is impossible to meet.
4. isValid always returns false without any indication that the constraint is not possible to meet
5. possible spec change to allow something like an InvalidConstraintException to be thrown by initialize(...)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 27, 2009 4:18 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
0. replace @Length with @Min @Max as it prevents the trap :)
and 1. is what I had in mind. i need to write up the exception part of the spec.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 5:48 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Started to review and test the current implementations of the builtin constraints and wonder the same thing.
Created a Jira issue for it: http://opensource.atlassian.com/project ... e/BVAL-117


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.