Query with GROUP BY

Hi

I have a Model with Data in a Timeline. Now i want in the Repository a findAll Method that only shows the currently active objects. They are defined with a tlAb (begin) and tlBis (end) where the end date can be set, but does not have to.
All belonging objects share same uid.
Now i want to show only the currently active versions of those uid’s

$query->matching(
    $query->logicalAnd(
        $query->lessThanOrEqual('tlAb', $time),
        $query->logicalOr(
            $query->greaterThanOrEqual('tlBis', $time),
            $query->equals('tlBis', null)
        )
    )
);
$query->setOrderings(array(
    'uid' => QueryInterface::ORDER_ASCENDING,
    'tlAb' => QueryInterface::ORDER_DESCENDING
));

This query actually shows all versions with tlAb in the past and tlBis in the future or not set.
But i want to narrow it down to only the newest version. So in SQL i would just do a

GROUP BY uid

But the GroupBy is not accessible through QueryInterface.

How is the best way to do this grouping?

Greetings
Beat

You could use DQL, that provides GROUP BY. See createDqlQuery($dqlString) in Flow\Persistence\Doctrine\Repository.