title: Why Spring Framework does not throw DuplicateKeyException when MySQLIntegrityConstraintViolationException occurs?
body: <p><code>DuplicateKeyException</code> extends <code>DataIntegrityViolationException</code>. However <code>DataIntegrityViolation</code> Exception is thrown by Spring framework if any unique key constraint is broken instead of <code>DuplicateKeyException</code>. </p>
  
  <p>I have an order table in which order code is unique. When I try to insert an order with an duplicate code, I'm expecting a DuplicateKeyException, however I am getting DataIntegrityViolationException.</p>
  
  <p>Here is the stack trace:</p>
  
  <pre><code>org.springframework.dao.DataIntegrityViolationException: Duplicate entry '1-561336327' for key 'code_UNIQUE'; SQL [n/a]; constraint [null]; nested exception is 
  org.hibernate.exception.ConstraintViolationException: Duplicate entry '1-561336327' for key 'code_UNIQUE' 
  com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1-561336327' for key 'code_UNIQUE' –
  </code></pre>
  
  <p>Anybody knows if this is expected?</p>