jamesfredley opened a new issue, #16714:
URL: https://github.com/apache/grails-core/issues/16714

   ## Summary
   
   #16625 wraps Groovy entity proxies in an extra subclass so `getMetaClass()` 
can be intercepted. `NameUtils.getClassName()` still unwraps only one `$` 
level, so GORM API lookup from that wrapper class no longer finds the entity.
   
   ## What goes wrong
   
   `GroovyProxyClassBuilder.wrap()` subclasses the Hibernate proxy class. The 
wrapper's simple name contains `$`, so `NameUtils.getClassName()` returns 
`getSuperclass().getName()`, which is now the Hibernate proxy class 
(`Author$HibernateProxy`) rather than `Author`. Before this merge the Hibernate 
proxy's superclass was the entity, and one unwrap was enough.
   
   `GormRegistry.normalizeEntityKey()` and `GormApiResolver.findDatastore()` 
both call `NameUtils.getClassName()` on a `Class`. A caller that resolves a 
GORM API from a proxy's runtime class, such as 
`GormRegistry.findValidationApi(proxy.getClass())`, looks up the Hibernate 
proxy name and gets null. Instance and static API lookup have the same miss.
   
   ## Introduced by
   
   - https://github.com/apache/grails-core/pull/16625
   - Merge commit `38216edf7b25b5b2216bcea6409b711b569168ed` on `8.0.x`
   - `GroovyProxyClassBuilder.java` line 83, through `NameUtils.getClassName()` 
and `GormRegistry.normalizeEntityKey()` line 811
   
   ## Fix
   
   Unwrap every proxy layer until the class is the persistent entity, in both 
Hibernate 5 and Hibernate 7, or avoid the extra superclass. Add a regression 
that `findValidationApi`, the instance API, and the static API resolve from the 
new wrapper class.
   


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