Hi,
first of, just working with the (
ConstraintViolation) messages is not enough. You will have to do a little bit more. First of you will have to validate manually so that you can control the validation. Or even better write your own
BeanValidationEventListener which listens to
PreInsertEvent,
PreUpdateEvent and
PreDelete (have a look at
https://github.com/hibernate/hibernate- ... tener.java). As you can see the default listener will always throw an exception on any validation error. There is no distinction between error or warning.
Once you have addressed the event listener issue you can look into distinguishing between error and warning messages. There are several ways to achieve this. You could for example place your constraints into different groups and first validate the 'error' group and then the 'warnings' group. If there are violations validating the warning groups you can react accordingly to your 'ignore warnings' flag.
Even better though would be to use the
payload attribute for constraints. You can then specify the severity level of a constraint as a payload. The payload will be available as part of the constraint violation. In fact this is the example used in the online docs for Hibernate Validator. Have a look there for more information.
--Hardy