diff --git a/source/blog/2022-01-11-orm-2.11.md b/source/blog/2022-01-11-orm-2.11.md index c89214ac..0cd5392b 100644 --- a/source/blog/2022-01-11-orm-2.11.md +++ b/source/blog/2022-01-11-orm-2.11.md @@ -88,14 +88,14 @@ Another PHP 8.1 feature is the new readonly keyword that prevents the value of a property to be written again after it has been initialized in the constructor of an object. -With ORM 2.11 the support now works as you would expect with no additional -mapping options necessary: +With ORM 2.11 the support now works only for entities which use the "NONE" +strategy for identifier generator: ```php #[Entity, Table(name: 'author')] class Author { - #[Column, Id, GeneratedValue] + #[Column, Id, GeneratedValue(strategy: 'NONE')] private readonly int $id; #[Column] @@ -103,6 +103,10 @@ class Author } ``` +For entities which use another strategy for their identifier generator, +it will not work because when an entity is removed, the Unit of Work +will try to set the value of the identifier as `null` which is not possible. + ## AssociationOverrides and AttributeOverrides in Attribute Driver The new `AttributeDriver` for PHP 8 did not support the equivalent mapping