borinquenkid commented on PR #16763:
URL: https://github.com/apache/grails-core/pull/16763#issuecomment-6539366329
Rebased onto `8.0.x` and squashed to commit `bb56460f51`, bringing Hibernate
7 in full alignment with the strategy and lifecycle refinements established in
#16784:
1. **Lazy connection gating (`dataSource.lazy=false`)**:
- Priming during `prepare()` is gated strictly by `lazyConnection ==
true`, ensuring idle outer sessions on non-lazy connection pools do not eagerly
check out connections.
- `wasPhysicallyConnectedAtPrepare` is tracked in
`AbstractOuterSessionLifecycleStrategy`. In `restore()`, physical connections
are disconnected via `disconnectIfConnected()` when
`!wasPhysicallyConnectedAtPrepare && (!lazyConnection ||
!previousActiveSynchronization)`, returning checked-out connections to the pool
and ensuring inner transactions under `PROPAGATION_SUPPORTS` do not leave
connections held by the outer session.
2. **Closed outer session handling**:
- `OuterSessionLifecycleStrategy.from(...)` checks `previousHolder !=
null` rather than `session.isOpen()`, routing closed bound sessions through
`DefaultOuterSessionStrategy` so that outer session holders are cleanly
suspended before `withNewSession` and restored upon scope exit.
3. **Exception translation and execution delegation**:
- New session execution delegates through `execute(callable::call)`,
ensuring flush modes (`FLUSH_EAGER`), `osivReadOnly`, and translation of
Hibernate exceptions to Spring `DataAccessException`
(`HibernateSystemException`) are preserved.
4. **Surface cleanups**:
- Removed unused `isLazyConnection()`, `transactionAware`, and 4-argument
constructors / factory overloads.
- Guarded DataSource lookups in transaction resource operations against
null references.
- Added test coverage in `WithNewSessionNonLazyPoolSpec`,
`WithNewSessionLazyLoadSpec`, and `GrailsHibernateTemplateSpec`.
--
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]