Empty ManyToMany collection after refresh inside PostPersist event #6692

Open
opened 2026-01-22 15:37:06 +01:00 by admin · 0 comments
Owner

Originally created by @jsakars on GitHub (Apr 12, 2021).

Using v2.7.3 of this library, I have a following case:

  • I have an entity (e.g. Book) for which some DB value (number) is calculated using DB trigger => therefore I need to refresh the entity during PostPersist event in order to have the value available further down the path (e.g. to have it indexed in the Elasticsearch)
  • I also have a ManyToMany Collection (e.g. Author) => for example one Author can have multiple Books and vice versa
  • the problem is that after doing the $em->refresh($book) within PostPersist Listener -> $authors collection is empty even though there are actual entries of course stored in the database even

Of course, I do have several 3rd party libraries (Gedmo Translatable, Blamable etc.) used which might have something to do with this.

What could be the cause of this?

Originally created by @jsakars on GitHub (Apr 12, 2021). Using v2.7.3 of this library, I have a following case: - I have an entity (e.g. `Book`) for which some DB value (number) is calculated using DB trigger => therefore I need to refresh the entity during `PostPersist` event in order to have the value available further down the path (e.g. to have it indexed in the Elasticsearch) - I also have a ManyToMany Collection (e.g. `Author`) => for example one `Author` can have multiple `Books` and vice versa - the problem is that after doing the `$em->refresh($book)` within `PostPersist` Listener -> `$authors` collection is empty even though there are actual entries of course stored in the database even Of course, I do have several 3rd party libraries (Gedmo Translatable, Blamable etc.) used which might have something to do with this. What could be the cause of this?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6692