Hibernate version:
3.2.4 with Validator 3.0.0.GA
R7943 added the ability to handle @Valid annotations on fields that are declared as a superclass of the actual value.
In theory, the classValidator for the field annotated @Valid should be in the childClassValidators collection. However, this collection is keyed on the declared class of the field - if the actual field value has a different class the validator will not be found. For this purpose a subclass counts as "different".
R9743 handles this by simply creating a new classValidator if the expected childClassValidator is not found.
However, unlike a normal child validator, the new validator created in this case is created using the minimal constructor and does not get passed any of the parent's state - in particular, the message bundle and the message interpolator. I'd love to know if there's a reason for this omission.
Assuming there isn't, I can think of three ways to go.
1. Just use the full constructor, like createChildClassValidator does
2. Actually call createChildClassValidator (not sure of the mechanics of creating an XMember instance)
3. Make the childClassValidators collection lookup aware of class hierarchy
I've checked in Jira and I can't see any issues that look like this.
Jaime Metcher
|