$qb = $this->createQueryBuilder('m')
->where('m.from = ?1 or m.to = ?1')
->groupBy('m.to')
->addGroupBy('m.from')
->orderBy('m.date', 'DESC')
->setParameter(1, $user->getId())
->setMaxResults($pagination) // limit
->setFirstResult($pagination * $page) // offset
;