I just started upgrading an application that used Hibernate 3.5.6.Final to 3.6.0.Final, and there has been several hickups. The last hickup I can't find a solution for.
3.6.0.Final seems to automatically turn on bean validation when an object is saved/updated through Hibernate. This is very bad because some of my tests don't bother setting all the properties - they just aren't needed. I honestly don't see the point to set every 'description' field and countless other fields just to comply with some arbitrary validation.
This is going to force me to spend hours making valid objects in all of my tests (I have over 1300 functional tests now). And frankly, it would be pointless because I am certain that all validation is happening in the MVC and there are no other ways to get data into the database currently.
I also don't want to incur a performance hit by validating my beans twice - once in the MVC, and then another time within Hibernate. It's just not needed in my case.
Is there a way I can turn this off? I am using Spring and regular Hibernate mapping files, not JPA (I dislike all the annotations).
Hibernate Validator allows to express and validate application constraints. The default metadata source are annotations, with the ability to override and extend through the use of XML. It is not tied to a specific application tier or programming model and is available for both server and client application programming.
The Javax bean validation API provides the following most frequently used annotations. The Hibernate validator provides the following commonly used annotations for validation. In case of product or project development we must use both the annotations for bean validation.
Validating constraintsValidator instances are thread-safe and may be reused multiple times.
Data validation is a common task that occurs in all layers of an application, including persistence. The Java™ Persistence API (JPA) 2.0 provides support for the Bean Validation API so that data validation can be done at run time.
Add the following to persistence.xml
:
<validation-mode>NONE</validation-mode>
or add the property to hibernate.cfg.xml
:
<property name="javax.persistence.validation.mode">none</property>
See 23.1.2. Configuration for more options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With