Using Hibernate Validator to validate all Strings fields in an entity as we pull data from our Oracle database.
There is a significant slow down when performing field-level validation on a collection of entities with multiple field constraints.
While retrieving ~72,000 entities from the database, each with 8 constraints, it takes 47 seconds to perform validation (only 3 seconds to retrieve data from the database).
Using only custom constraints and using only built-in constraints (@NotNull) show the same performance issue.
Some debugging shows that 46.5 seconds is spent after calling Validator.validate() and before reaching isValid().
However, when setting the annotation at class-level, manually performing the required reflection and string validation on the entity inside isValid(), it only takes 0.5 seconds to complete validation for all 72,000 entities.
Hibernate should be able to naively handle this magnitude of field-level validations without resorting to manual validation at a class-level.
Hibernate Validator 5.1.3
JDK 1.7.0 u65