Aug 29th, 2007, 05:40 PM
Using Hibernate Validator with Spring MVC
I'm working on a project that currently uses Spring's Validator interface with the implementation of our validation rules. We're finding it difficult to validate all changes made within our service tier while still taking advantage of Hibernate's silently cascading saves/updates.
We'd like to transition to Hibernate Validator annotations and refactor our Spring Validator classes to delegate validation to Hibernate and just transfer the error messages to the Errors object in the Spring validator.
The problem we have is that with Spring's validator, we were free to attach any error to any field. So, when a few fields combined to create a validation error, we just assigned it to the most likely field that the user may have screwed up.
In Hibernate's validator, the error's path is explicitly set to the place where the annotation lies, either on a field or on the bean (for validation checks that require multiple fields of a bean).
Has anyone had this kind of problem and devised a way to intelligently re-assign error paths when transferring them from InvalidValue to Spring's Errors object?