2

I'm using Bean Validation to check constraints on my model, but I don't know how to configure it so it only validates when I want it to. I found on that I could put this tag in my persistence.xml, <validation-mode>NONE</validation-mode> but it doesn't work.

I appreciate any kind of help.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
codenoob
  • 257
  • 3
  • 15
  • 1
    Which BV impl/version? Which JPA impl/version? Is this acceptable as dupe? http://stackoverflow.com/questions/3488702/how-do-you-turn-off-hibernate-bean-validation-with-jpa-1-0 It concerns JPA1 with Hibernate Validator, but also contains JPA2 hints. – BalusC May 27 '15 at 16:00
  • Hi @BalusC! I'm using JPA 2.1 and using Hibernates implementation of BV. I looked at the link you provided and tried to use `` but it didn't work. – codenoob May 27 '15 at 17:29
  • what you're trying to do is correct IMHO, and works for me with the JPA implementation I use (not Hibernate) – Neil Stockton May 27 '15 at 18:26

1 Answers1

4

I remember that i also had problems with that, here is my working example:

<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="punit" />
        <property name="jpaPropertyMap">
            <map>
                <entry key="javax.persistence.validation.mode" value="none"/>
            </map>
        </property>
    </bean>
jgr
  • 2,831
  • 2
  • 15
  • 28