borinquenkid commented on PR #16763:
URL: https://github.com/apache/grails-core/pull/16763#issuecomment-6537462904
Updated branch `fix/h7-withnewsession-connection-8.0.x` in commit
`67880b478c` bringing full architectural parity with the Hibernate 5
implementation on #16784:
1. **Lazy Connection Priming & Restore Disconnect**:
- `NonTransactionalSynchronizationOuterSessionStrategy`: Gated priming
during `prepare()` to `lazyConnection && !wasPhysicallyConnectedAtPrepare`.
- `AbstractOuterSessionLifecycleStrategy`: Disconnects on `restore()` if
the session was not physically connected at `prepare()` and either the data
source is non-lazy or no synchronization was active.
- `DefaultOuterSessionStrategy`: Removed eager priming so idle outer
sessions never check out connections on non-lazy connection pools.
2. **Session Holder & Resource Safety**:
- Closed outer sessions preserve their bound `SessionHolder` across
nested scopes by routing `previousHolder != null` to
`DefaultOuterSessionStrategy`.
- All `dataSource` transaction resource lookups, unbinds, and restores
are guarded against `null`.
3. **Exception Translation & Flush Delegation**:
- `GrailsHibernateTemplate.executeWithNewSession`: Delegates execution
through `execute(callable::call)` so that flush mode rules and exception
translation to Spring `DataAccessException` apply.
- Streamlined `cleanupNewSession` to unbind resources via
`unbindResourceIfPossible` without broad catch blocks.
4. **Test Coverage**:
- Added `WithNewSessionNonLazyPoolSpec.groovy` to
`grails-data-hibernate7-core` testing single-connection non-lazy pools
(`maxActive=1`, `dataSource.lazy=false`) across outer transaction disconnect,
inner transaction write, `PROPAGATION_SUPPORTS` scopes, and closed outer
session restoration.
- Extended `GrailsHibernateTemplateSpec.groovy` to verify eager flush
exception translation (`DataIntegrityViolationException`) and session holder
restoration on `openSession()` failure.
- Updated `OuterSessionLifecycleStrategySpec.groovy` with all 8 strategy
factory and lifecycle test cases.
--
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]