How to reload entity from database?

I have the case where a long polling request waits for modifications in an entity.

Basically the request uses a very simple notification mechanism to receive
an event from a separate http request that the entity has changed.
At this point i need to reload the entity and continue with the modified entity.

The modification request calls persistAll() right before the notification
and in the long polling request i just tried to re-read the entity using findByIdentifier()
without success. I assume some kind of caching/lazy-loading mechanism prevents quering the database.
I’m using development mode currently.

It should be noted that the modifications can also include OneToMany or OnetoOne relations or such.

So the question is: How to reload an entity from the database?
Or to ask it in another way: How to drop php entity modifications and reset the entity object to the current database line?


You can use PersistenceManagerInterface::clearState to clear the in-memory state of the persistence.