Joined: Tue Feb 05, 2013 5:51 am Posts: 1
|
Hi,
We have a web application where we are using Hibernate Persistence provider and Spring Transaction Manager. The Entities have validation annotated properties. The Hibernate Version is 4.1. By default the Validation in the persistence layer is activated in Hibernate 4.1 as the BeanValidationEventListener is registered using the service discovery in one of the jars.
Now when the validation kicks in during the commit phase. The BeanValidationEventListener throws a ConstraintViolationException if validation fails. This exception is wrapped under RollbackException by the Hibernate Session Manager and then again wrapped under Spring's TransactionSystemException by the spring transaction manager. It is very difficult for the caller service to know if the error is due to Constraint Violation as the caller has to get the lowest exception to find out the Constraints which caused the error.
Do we have any other mechanism to catch these exceptions.
Few thoughts: I don't want to disable the BeanValidationEventListener and call the Hibernate Validate method and handle exceptions. Can we override the BeanValidationEventListener?
|
|