@@ -151,40 +151,39 @@ type, which converts to/from UUID objects automatically::
151151 // ...
152152 }
153153
154- There's also a Doctrine generator to help autogenerate UUID values for the
155- entity primary keys::
154+ .. versionadded :: 5.2
156155
157- // there are generators for UUID V1 and V6 too
158- use Symfony\Bridge\Doctrine\IdGenerator\UuidV4Generator;
159- use Symfony\Component\Uid\Uuid;
156+ The UUID type was introduced in Symfony 5.2.
160157
161- /**
162- * @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
163- */
164- class Product
158+ There is no generator to assign UUIDs automatically as the value of your entity
159+ primary keys, but you can use instead the following::
160+
161+ namespace App\Entity;
162+
163+ use Doctrine\ORM\Mapping as ORM;
164+ // ...
165+
166+ class User implements UserInterface
165167 {
166168 /**
167169 * @ORM\Id
168- * @ORM\Column(type="uuid", unique=true)
169- * @ORM\GeneratedValue(strategy="CUSTOM")
170- * @ORM\CustomIdGenerator(class=UuidV4Generator::class)
170+ * @ORM\Column(type="ulid", unique=true)
171171 */
172172 private $id;
173173
174- // ...
174+ public function __construct()
175+ {
176+ $this->id = new Ulid();
177+ }
175178
176- public function getId(): ?Uuid
179+ public function getId(): Ulid
177180 {
178181 return $this->id;
179182 }
180183
181184 // ...
182185 }
183186
184- .. versionadded :: 5.2
185-
186- The UUID type and generators were introduced in Symfony 5.2.
187-
188187When using built-in Doctrine repository methods (e.g. ``findOneBy() ``), Doctrine
189188knows how to convert these UUID types to build the SQL query
190189(e.g. ``->findOneBy(['user' => $user->getUuid()]) ``). However, when using DQL
0 commit comments