matrei commented on issue #16556:
URL: https://github.com/apache/grails-core/issues/16556#issuecomment-6056096852
Thanks for the detailed report and the reproducer, they made this easy to
verify.
This was fixed before the 8.0.0 GA release by #16485 (commit 468ee47dfc,
"Respect mapped identifier getters in Hibernate proxies").
`ByteBuddyGroovyInterceptor` no longer matches `getId`/`getIdentifier` by name.
It now only short-circuits the exact `Method` that Hibernate resolved as the
identifier getter, which is the fix you suggested:
```java
// Only the mapped getter can return the identifier without invoking the
entity.
if (getIdentifierMethod != null && getIdentifierMethod.equals(method)) {
return getIdentifier();
}
```
The same change was made in `grails-data-hibernate7`, and
`ProxyIdentifierAccessSpec` adds a regression test for a business property
called `identifier`.
I ran your reproducer with only `grails8Version` changed:
| Grails | `getIdentifier() invoked reflectively on the proxy` | Result |
|---|---|---|
| 8.0.0-RC2 | FAILED (`ClassCastException`) | 4 tests, 1 failure |
| 8.0.0 | PASSED | 4 tests, 0 failures |
I'm closing this as fixed in 8.0.0. If you still see the problem in your
application after upgrading, please reopen the issue.
--
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]