borinquenkid commented on PR #16784:
URL: https://github.com/apache/grails-core/pull/16784#issuecomment-6515269984

   Thanks @jdaugherty for the detailed review and test scenarios. We have 
addressed both items:
   
   1. **Non-lazy connection pool handling (`dataSource.lazy=false`)**:
      - `lazyConnection` is now passed into 
`OuterSessionLifecycleStrategy.from(...)`.
      - Outer session priming during `prepare()` is restricted to 
`lazyConnection == true`, preventing premature connection checkouts on non-lazy 
pools.
      - `AbstractOuterSessionLifecycleStrategy` tracks 
`wasPhysicallyConnectedAtPrepare`. In `restore()`, the outer session is 
disconnected via `disconnectIfConnected()` (calling 
`logicalConnection.manualDisconnect()`) when `!wasPhysicallyConnectedAtPrepare 
&& (!lazyConnection || !previousActiveSynchronization)`. This ensures that any 
closed connection from an inner transaction is dropped, connection checkouts 
during the scope on non-lazy pools are returned to the pool, and active 
synchronizations retain lifecycle ownership when `lazyConnection == true`.
      - Added `WithNewSessionNonLazyPoolSpec` verifying single-connection 
non-lazy pools (`maxActive=1`, `lazy=false`) across non-transactional, 
transactional, `PROPAGATION_SUPPORTS`, and lazy-loading scenarios.
   
   2. **Exception translation and session settings in `withNewSession`**:
      - Decomposed `doExecute` in `GrailsHibernateTemplate` to extract 
`executeInSession` for callback execution and exception translation.
      - Restored `execute(callable::call)` delegation within 
`executeWithNewSession`. This preserves flush-mode application, `osivReadOnly`, 
and translation of Hibernate exceptions to Spring's `DataAccessException` 
(`HibernateSystemException`).
      - Added test coverage in `GrailsHibernateTemplateSpec` verifying that 
Hibernate exceptions thrown within `withNewSession` are translated to Spring's 
`DataAccessException`.


-- 
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]

Reply via email to