[hibernate-issues] [Hibernate-JIRA] Commented: (HV-21) Base class validations are not over-ridden

Emmanuel Bernard (JIRA) noreply at atlassian.com
Thu Jun 17 12:01:22 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37487#action_37487 ] 

Emmanuel Bernard commented on HV-21:
------------------------------------

This is the expected behavior in Bean Validation AFAIR because constraints are seen as contracts and not overridable implementation details. 
We won't change this behavior at least until we have a satisfying customizable solution. This is likely involve the porgrammatic API maybe with meta rules.

> Base class validations are not over-ridden
> ------------------------------------------
>
>                 Key: HV-21
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-21
>             Project: Hibernate Validator
>          Issue Type: Improvement
>          Components: legacy
>         Environment: hibernate 3.2 cr2
>            Reporter: Aseel Abbas
>             Fix For: 3.2.0
>
>
> When the same validation annotation is applied to an over-riding method in a subclass the expected behaviour is that the validation annotation in the base class is over-ridden.  Currently, both validations are executed.   This severely limits the usability of the package for domain models where inheritance is used.
> The problem also occurs with over-riding interfaces.
> For example:
> class A {
>    @Length (min = 0, max = 32)
>     Integer getFoo() {
>         return foo;
>     }
> }
> class B extends A
> {
>    @Length (min = 15, max = 20)
>     Integer getFoo() {
>         return super.getFoo();
>     }
> }
> In this case validating an instance of class B which has a foo value of 100 will result in two error messages: "foo must be between 15 and 20"  and  "foo must be between 0 and 32".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list