mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Is there any way of using DEFERRED_EXPLICIT globally? #7295
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @abcRede on GitHub (Jan 8, 2024).
We would like to exert control over the application's processes and explicitly mark what should be persisted. However, this necessitates modifying all classes to include the DEFERRED_EXPLICIT flag, posing a potential risk of overlooking some classes and leaving them behind.
While Doctrine/ORM appears to be a promising tool that could replace our current in-house developed ORM, we are hesitant about the concept of the entity manager monitoring everything and handling it automatically.
Given that we occasionally make changes in the model that aren't meant to be stored (as we operate financial software and run simulations over these models to generate the actual results of operations before storing the output), we need to exercise extreme caution. Cleaning every state before flushing entities is crucial. Therefore, having DEFERRED_EXPLICIT set by default would be the most suitable approach for us.
Our current method for handling these classes is similar to the following example:
Setting DEFERRED_EXPLICIT as the default would also facilitate code refactoring for us. Every instance where the "save" method is used could be replaced with "persist," streamlining the entire refactoring process.
Is there a way to implement this globally?
@ovrflo commented on GitHub (Jan 24, 2024):
Hi @abcRede
We implemented a subscriber that lets us know whenever we have an entity missing
DEFERRED_EXPLICIT.@abcRede commented on GitHub (Jan 24, 2024):
This is great! I'll give it a try.
Thank you very much!