From: Aseel A. (JIRA) <no...@at...> - 2006-05-18 14:31:21
|
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-344?page=comments#action_23128 ] Aseel Abbas commented on ANN-344: --------------------------------- I just tried @Pattern and it showed the same problem. By 'overlapping' do you mean overlapping annotation elements? For example: class A { @Length (min = 0, max = 32) Integer getFoo() { return foo; } } class B extends A { @Length (max = 20) Integer getFoo() { return super.getFoo(); } } then validating an instance of class B which has a foo value of 100 will result in: "foo must be between 0 and 20" I think this would be nice to have but not as important as allowing the whole annotation to be over-ridden. we need to apply a particular type of validator, e.g. @Length, once and only once to a given property. BTW the order by which the method org.hibernate.validator.ClassValidator<T>.addSuperClassesAndInterfaces<T>(XClass clazz, Collection<XClass> classes) adds superclasses and interfaces may be good enough to determine the precedence of validators. I wish JSR 175 had proper inheritance support... > Base class validations are not over-ridden > ------------------------------------------ > > Key: ANN-344 > URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-344 > Project: Hibernate Annotations > Type: Improvement > Components: validator > Versions: 3.2.0.cr1 > Environment: hibernate 3.2 cr2 > Reporter: Aseel Abbas > > > 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 |