I'm on a project team that is using Hibernate Validator to validate all Strings in Entity fields as we pull data from our database. We use Hibernate Validator 5.1.3, EclipseLink 2.5.2 and JPA 2.0.
There is a significant slow down when performing field level validation on a collection of entities with multiple field constraints. On one test we are retrieving ~72,000 entities from the database, each with 8 constraints. To validate all 72,000 entities, it takes 47 seconds, while without validation the test only takes 3 seconds to retrieve data from the database. We've tested using only our custom constraints and using only built-in constraints (@NotNull), both show the same performance issue. Some debugging shows that 46.5 seconds is spent after calling Validator.validate() and before reaching isValid().
However, when I set the annotation at class-level, and manually performing the required reflection and string validation on the entity inside isValid(), it only takes ~0.5 to complete validation for all 72,000 entities.
I would think Hibernate could naively handle this magnitude of field-level validation. I didn't see any performance issues reported for Hibernate Validator 5.1.3. Any suggestions?
Cheers, Andre
|