[PR #10735] Make it possible to have non-NULLable self-referencing associations when using application-provided IDs #12581

Closed
opened 2026-01-22 16:14:30 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/10735

State: closed
Merged: Yes


This change improves scheduling of extra updates in the BasicEntityPersister.

Extra updates can be avoided when

  • the referred-to entity has already been inserted during the current insert batch/transaction and the post-insert (database) ID is already available in the entity
  • we have a self-referencing entity with application-provided ID values (the NONE generator strategy).

As a corollary, with this change applications that provide their own IDs can define self-referencing associations as not NULLable.

One caveat, though: In the absence of entity-level commit ordering (#10547), it is not guaranteed that entities with self-references (at the class level) will be inserted in a suitable order. The order depends on the sequence in which the entities were added with persist().

Fixes #7877, closes #7882.

Co-authored-by: Sylvain Fabre sylvain.fabre@assoconnect.com

**Original Pull Request:** https://github.com/doctrine/orm/pull/10735 **State:** closed **Merged:** Yes --- This change improves scheduling of extra updates in the `BasicEntityPersister`. Extra updates can be avoided when * the referred-to entity has already been inserted during the current insert batch/transaction and the post-insert (database) ID is already available in the entity * we have a self-referencing entity with application-provided ID values (the `NONE` generator strategy). As a corollary, with this change applications that provide their own IDs can define self-referencing associations as not NULLable. One caveat, though: In the absence of entity-level commit ordering (#10547), it is not guaranteed that entities with self-references (at the class level) will be inserted in a suitable order. The order depends on the sequence in which the entities were added with `persist()`. Fixes #7877, closes #7882. Co-authored-by: Sylvain Fabre <sylvain.fabre@assoconnect.com>
admin added the pull-request label 2026-01-22 16:14:30 +01:00
admin closed this issue 2026-01-22 16:14:31 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12581