I am developing a service(not a web application) using Spring-3.1.0.GA. I want to use hibernate-validator along with Spring to validate my service inputs.
I have enabled the bean validation support with:
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
<bean class="org.springframework.validation.beanvalidation.MethodValidationPostProcessor"/>
I have annotated my service interface with @Validated and method parameters with @NotNull, @Size, @Valid etc and it is working fine.
But I have to validate my parameter, say Customer, based on validation group(s). If I annotate method parameter with @Validated or @Validated(Group1.class) Spring is not performing any validation.
If I annotate with @Valid then validations are happening but with Default validation group(as expected).
I can't annotate @Validate(Group1.class) at interface level because various methods operate on various groups.
How can I perform service layer validations using Spring and hibernate-validator with groups support?
<mvc:annotation-driven/>
toapplicationContext.xml
(although that would be for a Spring MVC application, which yours does not seem to be). - vegemite4me