I have 2 classes in a hierarchy: Parent and Child. Parent has property i and it's getter. Child overrides this getter. I have annotated getters in both files with @Range annotation with different ranges. And I hope validator will take in use overriden annotation when persisting child( in my example I need range(1,10) to be used).
When validation performs on persisting it takes only parent's annotation, but not child's (i.e. range(3,6)).
And application crushes, because actual value is not in parent's range.
Is there any means to enforce Validator to use child's annotation instead of parent's? If not - maybe it's a bug?
Beforehand thank you for any help.
Hibernate Validator version: 3.0.0
Code:
@Entity
public class Parent {
@Id
@GeneratedValue
private int id;
private Integer i;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Range(min=3, max=6)
public Integer getI() {
return i;
}
public void setI(Integer i) {
this.i = i;
}
}
@Entity
public class Child extends Parent{
@Range(min=1, max=10)
public Integer getI() {
return super.getI();
}
}