Copied from subtask as subtask of closed issue 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.
I also have some trouble within my Hibernate environment when it comes to validating (initialized) proxy instances. Beside the patch provided by Lucien I also have trouble with values returned by getter calls that are uninitialized proxy instances. Therefore I've wrapped the Validator.isValid() calls with an additional Hibernate.isInitialized(value) check.
The part of Lucien's patch regarding unproxying the bean instance will fail if the to be validated bean instance doesn't have an attached session instance any more. Therefore I've used the LazyInitializer.getImplementation() method for querying the wrapped bean instance of the proxy. I'm not sure if it's a good idea to always use the LazyInitializer class for getting the original bean instance but for me it's working fine with detached persistent entities.
I hope my provided patch (initialized-proxy-fix.patch) against the current 3.1.0.CR2 SVN branch is able to improve the validation results for beans wrapped by a Hibernate proxy instance.
Move issues into the legacy component since they are pre 3.x which is based on a different codebase
This is still very much an issue with Validator 4.0.2 GA. See attached updated test case which should only depend on Hibernate Annotations and Validator (change HibernateTestBase to org.hibernate.test.annotations.TestCase to run against Hibernate Annotations source).