title: SpringBoot doesn't handle org.hibernate.exception.ConstraintViolationException
body: <p>I have defined a pattern for validating email in my Entity class.  In my validation exception handler class, I have added handler for ConstraintViolationException.  My application utilize SpringBoot 1.4.5.</p>
  
  <p><strong>Profile.java</strong></p>
  
  <pre><code>@Entity
  @EntityListeners(AuditingEntityListener.class)
  @Table(name = "profile")
  public class Profile extends AuditableEntity {
  
    private static final long serialVersionUID = 8744243251433626827L;
  
    @Column(name = "email", nullable = true, length = 250)
    @NotNull
    @Pattern(regexp = "^([^ @])+@([^ \\.@]+\\.)+([^ \\.@])+$")
    @Size(max = 250)
    private String email;
  ....
  }
  </code></pre>
  
  <p><strong>ValidationExceptionHandler.java</strong></p>
  
  <pre><code>@ControllerAdvice
  public class ValidationExceptionHandler extends ResponseEntityExceptionHandler {
  
    private MessageSource messageSource;
  
    @Autowired
    public ValidationExceptionHandler(MessageSource messageSource) {
      this.messageSource = messageSource;
    }
  
    @ExceptionHandler(ConstraintViolationException.class)
    public ResponseEntity&lt;Object&gt; handleConstraintViolation(ConstraintViolationException ex,
    WebRequest request) {
      List&lt;String&gt; errors = new ArrayList&lt;String&gt;();
      ....
      }
  } 
  </code></pre>
  
  <p>When I run my code and pass invalid email address, I get the following exception. The code in handleConstraintViolation is never executed.  The http status returned in the exception is 500, but I want to return 400.  Any idea how I can achieve that?</p>
  
  <pre><code>2017-07-12 22:15:07.078 ERROR 55627 --- [nio-9000-exec-2] o.h.c.s.u.c.UserProfileController        : Validation failed for classes [org.xxxx.common.service.user.domain.Profile] during persist time for groups [javax.validation.groups.Default, ]
  List of constraint violations:[
  ConstraintViolationImpl{interpolatedMessage='must match "^([^ @])+@([^ \.@]+\.)+([^ \.@])+$"', propertyPath=email, rootBeanClass=class org.xxxx.common.service.user.domain.Profile, messageTemplate='{javax.validation.constraints.Pattern.message}'}]
  
  javax.validation.ConstraintViolationException: Validation failed for classes [org.xxxx.common.service.user.domain.Profile] during persist time for groups [javax.validation.groups.Default, ]
  List of constraint violations:[
  ConstraintViolationImpl{interpolatedMessage='must match "^([^ @])+@([^ \.@]+\.)+([^ \.@])+$"', propertyPath=email, rootBeanClass=class org.xxxx.common.service.user.domain.Profile, messageTemplate='{javax.validation.constraints.Pattern.message}'}]
  
  at  org.hibernate.cfg.beanvalidation.BeanValidationEventListener.validate(BeanValidationEventListener.java:138)
  
  at org.hibernate.cfg.beanvalidation.BeanValidationEventListener.onPreInsert(BeanValidationEventListener.java:78)    
  </code></pre>