How to disable Hibernate bean validation using JPA 1.0?

How to disable bean checking with Hibernate 3.x in JPA 1.0?

I tried several things with persistence.xml:

<persistence-unit name="bbstats" transaction-type="RESOURCE_LOCAL"> <properties> DB stuff <property name="javax.persistence.validation.mode" value="none" /> <property name="hibernate.validator.autoregister_listeners" value="false" /> </properties> <validation-mode>NONE</validation-mode> </persistence-unit> 

Last calling

 org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'validation-mode'. One of '{"http://java.sun.com/xml/ns/persistence":jta-data-source, "http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected. 

But none of this works. Can someone tell me how to do this in the implementation of JPA 1.0?

+6
validation hibernate
source share
1 answer

The javax.persistence.validation.mode property is one of the standardized properties of JPA 2.0. He did not expect it to work in a JPA 1.0 environment.

Actually, if you are using Hibernate Validator 4, my suggestion was to remove the JAR from the class path (I'm not sure if the configuration settings from Hibernate Validator 3 are still applicable).

And if you are using Hibernate Validator 3, the following should disable support for restrictions within the generated DDL and validate the object before inserting or updating:

 <property name="hibernate.validator.apply_to_ddl" value="false"/> <property name="hibernate.validator.autoregister_listeners" value="false"/> 

But removing the JAR from the class path would also be straightforward.

If you encounter a more specific problem, provide more details (including the version of Hibernate Validator).

References

+6
source share

All Articles