[hibernate-issues] [Hibernate-JIRA] Created: (HV-433) Cascaded validation on superclass fields does not work if only @valid is used

Christian Quanz (JIRA) noreply at atlassian.com
Thu Feb 10 10:14:07 EST 2011


Cascaded validation on superclass fields does not work if only @valid is used
-----------------------------------------------------------------------------

                 Key: HV-433
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-433
             Project: Hibernate Validator
          Issue Type: Bug
    Affects Versions: 4.1.0.Final
         Environment: Java 1.5.0 (IBM J9 2.3); Hibernate Validator 4.1.0.FINAL
            Reporter: Christian Quanz


Cascaded fields are not validated if the following applies:
- Only @valid is specified for a particular field, no further constraints
- Validation takes place on an object of a sublcass of the class where the field to be validated is defined

Simply no validation will take place on the object assigned to the field. Eyerything works fine if I add another constraint definition, e.g., @NotNull to the field, as in the examples in the documentation. If I validate an object of the class where the field is defined, it also works. I doubt that it matters, but the field's visibility is "protected".

I tested it for XML constraint definitions and programmatic constraint definitions.

I could trace the error back to BeanMetaDataImpl->initFieldConstraints(...), where the flag cachedFieldIsCascaded will be false. Thus, addCascadedMember(...) will not be called for the field.
In case of any additional constraint being defined, the flag cachedFieldIsCascaded will be true.

Hope that helps.

-- 
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