title: Throw duplicatekeyexception in JPA/Hibernate/Spring
body: <p>I'm trying to migrate my code from JdbcTemplate to JPA. I am used to having <code>DuplicateKeyException</code> being thrown when an insert is being performed on a unqiue constraint. I was wondering how do I get JPA to throw a <code>DuplicateKeyException</code>? Or if there is a better alternative to throwing exceptions for duplicatekeys.</p>
  
  <p>EDIT: <br>
  The exception I usually get is <code>DataIntegrityViolationException</code> instead of <code>DuplicateKeyException</code></p>