public void saveCategory(List<Category> categories) throws DuplicateKeyException { boolean duplicateKeyException = false; for (Category category : categories) { try { super.save(category); } catch (DuplicateKeyException e) { duplicateKeyException = true; e.printStackTrace(); } } if (duplicateKeyException) { throw new DuplicateKeyException(); } }
public void saveCategory(Category category) throws DuplicateKeyException { super.save(category); }