public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
if ($this->criteriaRequiresDql($criteria) === FALSE && $this->criteriaRequiresDql((array) $orderBy) === FALSE) {
return parent::findBy($criteria, $orderBy, $limit, $offset);
}
$qb = $this->createQueryBuilder('e')->whereCriteria($criteria)->autoJoinOrderBy((array) $orderBy);
return $qb->getQuery()->setMaxResults($limit)->setFirstResult($offset)->getResult();
}