[hibernate-issues] [Hibernate-JIRA] Commented: (HV-64) Field annotated member validators does not work with proxied objects
Lucien Weller (JIRA)
noreply at atlassian.com
Mon Aug 18 11:29:38 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HV-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30922 ]
Lucien Weller commented on HV-64:
---------------------------------
Ok, my first patch was a quick fix that works in our case because our beans are pojo's with simple getter/setters. So I tried to go a little bit further and found a solution where proxies could be handled correctly withoud changin the current semantic. The diadvanage is that this fix has a dependency to hibernate-core (but as a saw in pom of hobernate validator, this dependency is already requiredm so I think it does not matter).
I hope that this new patch will help you and lead to a reopening of this issue (I couldn't repoen it my myself because I don't have enough right's).
> 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.0.0.ga, 3.1.0.CR1
> 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