Copilot commented on code in PR #16521:
URL: https://github.com/apache/grails-core/pull/16521#discussion_r4185440627
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy:
##########
@@ -289,7 +289,8 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
}
} else {
// for non multi-tenant entities we process get(..) via the second
level cache
- (D) hibernateTemplate.execute { Session session ->
session.find(persistentEntity.javaClass, id) }
+ (D) proxyHandler.unwrap(
+ hibernateTemplate.execute { Session session ->
session.find(persistentEntity.javaClass, id) })
Review Comment:
Consider moving `proxyHandler.unwrap(...)` *inside* the
`hibernateTemplate.execute { ... }` callback. If `unwrap()` triggers proxy
initialization (common for Hibernate proxies), doing it after `execute` returns
can run outside the template-managed/session-bound work and may cause
`LazyInitializationException` depending on how `HibernateTemplate` manages the
session in this path. Wrapping inside the callback ensures unproxying occurs
while the session is definitely available.
--
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]