'Symfony - Could not convert database value to uuid
In my Symfony project I am using \Ramsey\Uuid\Uuid library for persisting user object with unique uuid.
$user->setUUid(Uuid::uuid4());
No I want to search for an user object by that uuid like:
$uuid = $this->userRepo->findOneBy(['uuid' => $uuid]);
And I am passing it trough my request like:
http://localhost:8080/api/user/039ade1a-c111-419c-9904-67b62162208
but I get:
"Could not convert database value "039ade1a-c111-419c-9..." to Doctrine Type uuid"
Should I somehow convert it again to uuid?
I tried:
return $this->createQueryBuilder('p')
->where('p.uuid = :uuid')
->setParameters(
'uuid' => Uuid::fromString($uuid)->getBytes()
)
->getQuery()
->getOneOrNullResult();
Error still the same.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
