Disable Hibernate validation for a single entity

Viewed 113

I'd like to disable Hibernate validation for a single entity in my application, which I validate manually. The rest of entites should continue to use the standard Hibernate validation on persist.

The standard solution is to disable all validation via javax.persistence.validation.mode: none but this doesn't apply here as I just want to bypass it for a single entity.

So far the solutions appear to be:

  1. Add Hibernate groups to every single annotation on the entity - this is error prone and cumbersome as the entity has 50+ annotations on it.
  2. Replace or override BeanValidationEventListener to skip validation for my entity - there doesn't appear to be a clean way to override this listener with Spring Boot 2.0.

Are there other, simpler ways to do this with Hibernate and Spring?

0 Answers
Related