When a unique constraint is violated, a javax.persistence.RollbackException is thrown. But there could be multiple reasons to throw a RollbackException
javax.persistence.RollbackException
RollbackException
Use e.getCause() to examine what caused the rollback.
e.getCause()