[hibernate-issues] [Hibernate-JIRA] Created: (HV-64) Field annotated member validators does not work with proxied objects

Lucien Weller (JIRA) noreply at atlassian.com
Fri Aug 8 04:33:30 EDT 2008


Field annotated member validators does not work with proxied objects
--------------------------------------------------------------------

                 Key: HV-64
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-64
             Project: Hibernate Validator
          Issue Type: Bug
          Components: engine
    Affects Versions: 3.1.0.CR1, 3.0.0.ga
            Reporter: Lucien Weller
         Attachments: getter-fix.patch

Every thing works fine, except when I try to validate an persistent instance laded directly from database (which should obviously be valid) we get some invalid values reported by hibernate class validator.

After debuging hibernate validator code, I discovered that it is because we annotate our hibernate classes on field level with validator anotaions (getter and setter are generated in our project). Hibernate validator then tries to retrive the value directly by accessing the field it self. But if the instance is a proxied object (due to lazy loading), fields don't hold the correct value (in fact they all set to null) and validator then reports an invalid value if field is annotated with not null validator.

I simply fixed this isse by accessing fields with their getter rather than by a direct access if a getter has been defined. Now validation also works fine with persistent proxied instances loaded from database.

The corresponding patch is attached to the present issue report, hoping this will be fixed in 3.1.0.GA release

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