哪个是使用extbase创建页面的最佳方法?

i have seen that are two ways to create new pages with extbase, once with datamap like this:

$data = array(
 ‚pages‘ => array(
 ‚NEW_1‘ => array(
   ‚pid‘ => 1,
   ‚title‘ => ‚Hello World‚
 ),
)
); 

$tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
$tce->start($data, array());
$tce->process_datamap();
\TYPO3\CMS\Backend\Utility\BackendUtility::setUpdateSignal('updatePageTree');
$tce->clear_cacheCmd('pages');

And the other way with mapping like this

Model

class Pages extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity{
…
}

Repository

   class PagesRepository extends \TYPO3\CMS\Extbase\Persistence\Repository {
 …
}

Controller

$page->setTitle('Hell World');
$this->pagesRepository->add($page);

TypoScript

persistence{
        classes{
        <Vendor>\<extKey>\Domain\Model\Pages{
          mapping{
           tableName = pages
           columns{
            title.mapOnProperty = title
            …
           }
          }     
        }
       }
}

Which one should I use to create pages and what is the difference between both of them?

I would go the the approach using the DataMapper as it takes better care about the interals of TYPO3 like the refindex.

If I would need to create a custom model with relations, I would use extbase as it is just less work.