borinquenkid commented on PR #16784: URL: https://github.com/apache/grails-core/pull/16784#issuecomment-6511547493
We have refactored outer session lifecycle handling in `executeWithNewSession` to use dedicated `OuterSessionLifecycleStrategy` implementations matching the isolation requirements of each scope: - **`ActiveTransactionOuterSessionStrategy`**: When an outer transaction is active, the outer session is suspended and rebound without disconnecting, preserving active transaction state and flushed changes. - **`NonTransactionalSynchronizationOuterSessionStrategy`**: In non-transactional scopes under active synchronization (e.g. OSIV), the outer session eagerly primes its connection so that lazy loads inside the new session's transaction do not borrow the inner connection, unbinds the session holder during new session execution, and registers synchronization to disconnect the outer session prior to Spring JDBC connection cleanup. - **`DefaultOuterSessionStrategy`**: Handles outer sessions where synchronization is inactive by unbinding before the new session runs and restoring it upon completion. - **`TransactionResources`**: Abstracts Spring's `TransactionSynchronizationManager` interactions for full decoupling and testability. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
