8080 * length?: int,
8181 * id?: bool,
8282 * nullable?: bool,
83+ * notInsertable?: bool,
84+ * notUpdatable?: bool,
85+ * generated?: string,
8386 * enumType?: class-string<BackedEnum>,
8487 * columnDefinition?: string,
8588 * precision?: int,
@@ -258,6 +261,21 @@ class ClassMetadataInfo implements ClassMetadata
258261 */
259262 public const CACHE_USAGE_READ_WRITE = 3 ;
260263
264+ /**
265+ * The value of this column is never generated by the database.
266+ */
267+ public const GENERATED_NEVER = 0 ;
268+
269+ /**
270+ * The value of this column is generated by the database on INSERT, but not on UPDATE.
271+ */
272+ public const GENERATED_INSERT = 1 ;
273+
274+ /**
275+ * The value of this column is generated by the database on both INSERT and UDPATE statements.
276+ */
277+ public const GENERATED_ALWAYS = 2 ;
278+
261279 /**
262280 * READ-ONLY: The name of the entity class.
263281 *
@@ -439,6 +457,12 @@ class ClassMetadataInfo implements ClassMetadata
439457 * - <b>nullable</b> (boolean, optional)
440458 * Whether the column is nullable. Defaults to FALSE.
441459 *
460+ * - <b>'notInsertable'</b> (boolean, optional)
461+ * Whether the column is not insertable. Optional. Is only set if value is TRUE.
462+ *
463+ * - <b>'notUpdatable'</b> (boolean, optional)
464+ * Whether the column is updatable. Optional. Is only set if value is TRUE.
465+ *
442466 * - <b>columnDefinition</b> (string, optional, schema-only)
443467 * The SQL fragment that is used when generating the DDL for the column.
444468 *
@@ -659,13 +683,21 @@ class ClassMetadataInfo implements ClassMetadata
659683 */
660684 public $ changeTrackingPolicy = self ::CHANGETRACKING_DEFERRED_IMPLICIT ;
661685
686+ /**
687+ * READ-ONLY: A Flag indicating whether one or more columns of this class
688+ * have to be reloaded after insert / update operations.
689+ *
690+ * @var bool
691+ */
692+ public $ requiresFetchAfterChange = false ;
693+
662694 /**
663695 * READ-ONLY: A flag for whether or not instances of this class are to be versioned
664696 * with optimistic locking.
665697 *
666698 * @var bool
667699 */
668- public $ isVersioned ;
700+ public $ isVersioned = false ;
669701
670702 /**
671703 * READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
@@ -963,6 +995,10 @@ public function __sleep()
963995 $ serialized [] = 'cache ' ;
964996 }
965997
998+ if ($ this ->requiresFetchAfterChange ) {
999+ $ serialized [] = 'requiresFetchAfterChange ' ;
1000+ }
1001+
9661002 return $ serialized ;
9671003 }
9681004
@@ -1611,6 +1647,16 @@ protected function validateAndCompleteFieldMapping(array $mapping): array
16111647 $ mapping ['requireSQLConversion ' ] = true ;
16121648 }
16131649
1650+ if (isset ($ mapping ['generated ' ])) {
1651+ if (! in_array ($ mapping ['generated ' ], [self ::GENERATED_NEVER , self ::GENERATED_INSERT , self ::GENERATED_ALWAYS ])) {
1652+ throw MappingException::invalidGeneratedMode ($ mapping ['generated ' ]);
1653+ }
1654+
1655+ if ($ mapping ['generated ' ] === self ::GENERATED_NEVER ) {
1656+ unset($ mapping ['generated ' ]);
1657+ }
1658+ }
1659+
16141660 if (isset ($ mapping ['enumType ' ])) {
16151661 if (PHP_VERSION_ID < 80100 ) {
16161662 throw MappingException::enumsRequirePhp81 ($ this ->name , $ mapping ['fieldName ' ]);
@@ -2675,6 +2721,10 @@ public function mapField(array $mapping)
26752721 $ mapping = $ this ->validateAndCompleteFieldMapping ($ mapping );
26762722 $ this ->assertFieldNotMapped ($ mapping ['fieldName ' ]);
26772723
2724+ if (isset ($ mapping ['generated ' ])) {
2725+ $ this ->requiresFetchAfterChange = true ;
2726+ }
2727+
26782728 $ this ->fieldMappings [$ mapping ['fieldName ' ]] = $ mapping ;
26792729 }
26802730
@@ -3405,8 +3455,9 @@ public function setSequenceGeneratorDefinition(array $definition)
34053455 */
34063456 public function setVersionMapping (array &$ mapping )
34073457 {
3408- $ this ->isVersioned = true ;
3409- $ this ->versionField = $ mapping ['fieldName ' ];
3458+ $ this ->isVersioned = true ;
3459+ $ this ->versionField = $ mapping ['fieldName ' ];
3460+ $ this ->requiresFetchAfterChange = true ;
34103461
34113462 if (! isset ($ mapping ['default ' ])) {
34123463 if (in_array ($ mapping ['type ' ], ['integer ' , 'bigint ' , 'smallint ' ], true )) {
@@ -3429,6 +3480,10 @@ public function setVersionMapping(array &$mapping)
34293480 public function setVersioned ($ bool )
34303481 {
34313482 $ this ->isVersioned = $ bool ;
3483+
3484+ if ($ bool ) {
3485+ $ this ->requiresFetchAfterChange = true ;
3486+ }
34323487 }
34333488
34343489 /**
0 commit comments