From 5571393d8aa3c834afa25be3584ab19867d5b430 Mon Sep 17 00:00:00 2001 From: Nahuel Mora Date: Mon, 17 Apr 2023 14:06:59 -0300 Subject: [PATCH] Update `2022-01-11-orm-2.11.md` to be clear about some limitations over "Support for Readonly Properties" --- source/blog/2022-01-11-orm-2.11.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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