@Override
 public void preUpdate(DescriptorEvent event) {
   Object source = event.getSource();
   UnitOfWorkImpl unitOfWork = (UnitOfWorkImpl) event.getSession();
   // preUpdate is also generated for deleted objects that were modified in this UOW.
   // Do not perform preUpdate validation for such objects as preRemove would have already been
   // called.
   if (!unitOfWork.isObjectDeleted(source)) {
     validateOnCallbackEvent(event, "preUpdate", groupPreUpdate);
   }
 }
 private void validateOnCallbackEvent(
     DescriptorEvent event, String callbackEventName, Class[] validationGroup) {
   Object source = event.getSource();
   boolean shouldValidate = BEAN_VALIDATION_HELPER.isConstrained(source.getClass());
   if (shouldValidate) {
     Set<ConstraintViolation<Object>> constraintViolations =
         getValidator(event).validate(source, validationGroup);
     if (constraintViolations.size() > 0) {
       // There were errors while call to validate above.
       // Throw a ConstrainViolationException as required by the spec.
       // The transaction would be rolled back automatically
       // TODO need to I18N this.
       throw new ConstraintViolationException(
           "Bean Validation constraint(s) violated while executing Automatic Bean Validation on callback event:'"
               + callbackEventName
               + "'. Please refer to embedded ConstraintViolations for details.",
           (Set<ConstraintViolation<?>>)
               (Object) constraintViolations); /* Do not remove the explicit
                       cast. This issue is related to capture#a not being instance of capture#b. */
     }
   }
 }