File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,35 @@ type, which converts to/from UUID objects automatically::
155
155
156
156
The UUID type was introduced in Symfony 5.2.
157
157
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
167
+ {
168
+ /**
169
+ * @ORM\Id
170
+ * @ORM\Column(type="ulid", unique=true)
171
+ */
172
+ private $id;
173
+
174
+ public function __construct()
175
+ {
176
+ $this->id = new Ulid();
177
+ }
178
+
179
+ public function getId(): Ulid
180
+ {
181
+ return $this->id;
182
+ }
183
+
184
+ // ...
185
+ }
186
+
158
187
When using built-in Doctrine repository methods (e.g. ``findOneBy() ``), Doctrine
159
188
knows how to convert these UUID types to build the SQL query
160
189
(e.g. ``->findOneBy(['user' => $user->getUuid()]) ``). However, when using DQL
You can’t perform that action at this time.
0 commit comments