I’m using Doctrine 2, and would like this ORM to auto flush() the EntityManager before executing any SELECT query, to ensure consistency at all times within the application (this application is abstracting a lot, and should not have any knowledge of the EntityManager, apart from inside the Repositories).
Is there an option to do that with Doctrine?
If not, any strategy to implement this easily?
The only solution I’ve found so far, is to manually
flush()before issuing aSELECTquery in the repository methods that must not return stale data:This way, the flush is hidden from the services that consume the repositories.