codenoob
codenoob

Reputation: 257

How to disable automatic Bean Validation in JPA entities

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.

Upvotes: 2

Views: 2345

Answers (1)

jgr
jgr

Reputation: 2931

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>

Upvotes: 4

Related Questions