ramsey / uuid-doctrine

:snowflake::file_cabinet: Allow the use of a ramsey/uuid UUID as Doctrine field type.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should i pass uuid into a id variable in the entity constructor?

PaYo90 opened this issue · comments

In regular uuid we do that. with uuid-doctrine, i dont know if should i do that. Documentattion says nothing about this, but when i try to inicialize entity in the controller, and give a ID value of that entity in the next entity before flush, the ID isEmpty. What should i write, now?

If you're using the UUID as an ID, you can use the UuidBinaryType with @GeneratedValue - works very well. If you are otherwise using the popular public-id-with-private-uuid method, then Doctrine supports only one @GeneratedValue. You'll put @GeneratedValue on your @Orm\Id integer, and you can push the UUID into the constructor, or assume it within the constructor. YMMV.