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

Chris Wilson (JIRA) noreply at atlassian.com
Thu Feb 4 08:55:31 EST 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HV-76?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=35471#action_35471 ] 

Chris Wilson commented on HV-76:
--------------------------------

It's not perfect, but if you don't want to patch Annotations you can use this [alternative Validator|http://rita.wfplogistics.org/trac/browser/rita/src/org/wfp/rita/db/HibernateProxyValidator.java] like this:

{code}
Set errors = new HibernateProxyValidator().validate(person);
{code}

>  Field annotated member validators does not work with proxied objects
> ---------------------------------------------------------------------
>
>                 Key: HV-76
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-76
>             Project: Hibernate Validator
>          Issue Type: Bug
>          Components: legacy
>    Affects Versions: 3.0.0.ga, 3.1.0.CR1
>            Reporter: Lucien Weller
>             Fix For: 3.2.0
>
>         Attachments: HibernateValidatorFieldAnnotationsAndProxiesTest.java, initialized-proxy-fix.patch, proxy-fix.patch, testcase.tar.gz
>
>
> Copied from subtask HV-68 as subtask of closed issue HV-64 seams not to appear as open issue):
> May be annotating validation constraints on field level ist not the best solution, but by now it's explicitly mentioned as a possibility without other indication of restrictions in hibernate validator doc. But obviously this method is not safe with hibernate proxy instances as it is demonstrated be test case attached to original issue (http://opensource.atlassian.com/projects/hibernate/secure/attachment/14092/testcase.tar.gz). My first patch was a quick fix that worked for our case and a agree once again that it may have some side effects as it changes the semantic of field annotation. but my second solution (http://opensource.atlassian.com/projects/hibernate/secure/attachment/14091/proxy-fix.patch) leaves every thing as it is and just handles proxy instances differently and produce a more correct validation result than in current version.
> I hope that you can do something with my ideas or a least document this limitation when using field annotation. 

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