Make getAutoId test the existence of the new id before assignment.