Does Spring validation support the Hibernate JSR 303 implementation option for fast fast mode?

8.2. Quick shutdown

I'm looking for where I can configure this option in Spring, but I'm not sure if this is part of JSR 303, as this is a Hibernate configuration for the native implementation of the validator. This is important, because if I have multiple violations of restrictions, I want the first to be β€œthrown”.

+4
source share
1 answer

Assuming you are using Spring LocalValidatorFactoryBean to configure your validator, you can specify vendor-specific configuration parameters in the validationPropertyMap attribute.

The fail-fast attribute property name of the Hibernate Validator is "hibernate.validator.fail_fast", so you should configure your validator as follows:

 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> <bean name="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> <property name="validationPropertyMap"> <util:map> <entry key="hibernate.validator.fail_fast" value="true"/> </util:map> </property> </bean> </beans> 
+4
source

Source: https://habr.com/ru/post/1415774/


All Articles