Refactor UnitOfWork::doMerge() based on ORM