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
The call to withNewSession in the listener should be removed as it isn't occurring in the same transactional context as the caller anymore.
Audit logging should be atomic to the transaction making the changes such that both commit or rollback together. Previously, withNewSession was useful to prevent contaminating the outer session.
The text was updated successfully, but these errors were encountered:
Doing a bit more testing, it actually is required in some cases as the listener is being called during a flush and should add anything else to the session in that case. However, it's not clear with the withNewSession behavior if the transactional context is preserved. One option could be to defer the actual save logic until after successful commit of the transaction by using TransactionSynchronizationManager.registerSynchronization and add an afterCommit handler.
That might not be a bad idea anyway since it would defer any impact of the audit log until successful commit in all cases (not just in the flushMode = COMMIT) case.
Per behavior changes in:
grails/grails-data-mapping#1130
The call to
withNewSession
in the listener should be removed as it isn't occurring in the same transactional context as the caller anymore.Audit logging should be atomic to the transaction making the changes such that both commit or rollback together. Previously,
withNewSession
was useful to prevent contaminating the outer session.The text was updated successfully, but these errors were encountered: