[Flow] custom query with limit

Hi,

i’ve the following problem. I use the \TYPO3\Flow\Persistence\Doctrine\Repository for one of my repositories because i have a completely individual query. In that query i use groupBy, orderBy and also limit. The problem is to set the limit. My DQL completely ignore the limit values. But i don’t know why.

Here an example of my Query:

$builder = $this->entityManager->createQueryBuilder('\Orangefluid\Orangelab\Domain\Model\TimeTracking');
$builder->select(array('tt','sum(tt.period) as period, max(tt.date) as maxDate'))
->from('\Orangefluid\Orangelab\Domain\Model\TimeTracking', 'tt');

if(!empty($from) && !empty($to)) {
$builder->where('tt.date >= '.$from)->andWhere('tt.date <= '.$to);
}

if(!empty($user)){
$builder->andWhere('tt.user = ' .$user->getUid());
}
$group = intval($group);
if($group === 1) {
$builder->groupBy('tt.project');
}else {
$builder->groupBy('tt.uid');
}

$builder->orderBy('maxDate', 'DESC');
$builder->setFirstResult(0);
$builder->setMaxResults(10);

$query = $builder->getDQL();

$tmpReports = $this->entityManager->createQuery($query)->execute();

Can anyone help me? Or can i do that query with the flow basics too?

Thanks

DQL ist the way to go, but I would probably also ask in the Doctrine IRC or forums as this has nothing to do with Flow. You might want to debug the resulting SQL query, maybe that gives you some hints, but I have no good idea.