$createdAtCondition = new \DateTime('now -30 days');
$queryBuilder = $this->createQueryBuilder('cd')
->where('cd.createdAt > :createdAt')
->andWhere('cd.stepNr = :stepNr')
->andWhere("JSON_CONTAINS(cd.serializedData, :pesel, '$.pesel') = 1");
//$queryBuilder->setParameter('pesel', ".$keyValue.");
$queryBuilder->setParameter('createdAt', $createdAtCondition);
$queryBuilder->setParameter('stepNr', $lastStepNumber);
$queryBuilder->setParameter('pesel', '"'.$keyValue.'"');
$queryBuilder->orderBy('cd.createdAt', 'DESC')->setMaxResults(1);
return $queryBuilder->getQuery()->getSingleResult();