title: How to get the MySQLIntegrityConstraintViolationException message in hibernate
body: <p>Im trying to handle exception</p>
  
  <p>this is the stacktrace;</p>
  
  <pre><code>org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) 
      ...
      ...
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'testemail@gmail.com' for key 'UK_n7ihswpy07ci568w34q0oi8he'
  </code></pre>
  
  <p>when I try to get the messsase using the getMessage() method, the message get was the "could not execute statement" from ConstraintViolationException, </p>
  
  <p>but what I want is to get the 
  "Duplicate entry 'testemail@gmail.com' for key 'UK_n7ihswpy07ci568w34q0oi8he'" message from MySQLIntegrityConstraintViolationException.</p>
  
  <p>here is my catching process</p>
  
  <pre><code>catch(MySQLIntegrityConstraintViolationException e){
      e.printStackTrace();
      message = "MySQLIntegrity,\n Duplicate Entry, \n" + e.getMessage();
  }
  catch(ConstraintViolationException e){
      e.printStackTrace();
      message = "ConstraintViolation,\n Duplicate Entry, \n" + e.getMessage();
  }
  catch (Exception e) {
      e.printStackTrace();
      message = "Exception rule,\n" + e.getMessage();
  }
  </code></pre>