The alternative would be throwing an exception as soon as a problem has been detected. These would have to be more specific exceptions (e.g. DuplicateKeyConstraintViolationException) so users can react appropriately. The former approach sound better to me, though.