Spring Transactions and Exceptions

Categories: Java

Question: does the following Java/Spring-Data code actually throw a DuplicateAccount exception when a DB uniqueness constraint is violated?

public Account addAccount(..) throws DuplicateAccount {
  try {
    Account account = ...
    accountDao.save(account);
  } catch(DataIntegrityViolationException e) {
    throw new DuplicateAccount();
  }
}

The answer is - it depends.