Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Won't Fix
-
Affects Version/s: 1.6
-
Fix Version/s: 1.6.2, 1.7-beta-1
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
I've attached an example script that demonstrates an issue with Groovy callsite caching when combined with Hibernate proxy usage. Accessing an association of an entity that is lazily loaded with a Hibernate proxy results in an IllegalArgumentException:
java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
This has is causing this issue in Grails: http://jira.codehaus.org/browse/GRAILS-4230
To add a little more detail. This is the line that causes the problem:
It happens when accessing the "author" property of the "content" association. The "author" property is defined in a subclass called Article, what is interesting is that accessing properties from the parent class works fine: