You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tl;dr: Is there any way of determining whether a DAO entity is being inserted, deleted or updated in the current transaction?
Context: I am maintaining an entity change tracker that needs to detect:
every insert (table, entity id)
every update (table, entity id, updated column, previous and current values)
every delete (table, entity id)
Leveraging Exposed's EntityHooks I get notified about the inserts and deletes but the updates get flushed before I am able to extract the updated values from writeValues and readValues. See the source.
This has lead me to extract the changes by overriding the entity flush function and log the changes before forwarding to the original flush, but then I cannot differentiate between updated and inserted entities. My best bet currently is to access the internal isNewEntity function via reflection.
Hence the question: is there any recommended way I can determine entity state? Or is there some other less convoluted approach I can take to implement my change tracker?
The text was updated successfully, but these errors were encountered:
Hi,
I took a look at the code as well, and from what I can tell, there's no better way at the moment.
The reason the flush occurs before notifying listeners is to avoid race conditions (see 0.40.0 bugs section).
I think it's worth considering making isNewEntity function public instead of internal.
tl;dr: Is there any way of determining whether a DAO entity is being inserted, deleted or updated in the current transaction?
Context: I am maintaining an entity change tracker that needs to detect:
Leveraging Exposed's EntityHooks I get notified about the inserts and deletes but the updates get flushed before I am able to extract the updated values from writeValues and readValues. See the source.
This has lead me to extract the changes by overriding the entity flush function and log the changes before forwarding to the original flush, but then I cannot differentiate between updated and inserted entities. My best bet currently is to access the internal isNewEntity function via reflection.
Hence the question: is there any recommended way I can determine entity state? Or is there some other less convoluted approach I can take to implement my change tracker?
The text was updated successfully, but these errors were encountered: