Hi all,
Just wondering if anyone had run into this issue:
When we iterate over a collection of hibernate objects that are javassist-instrumented Hibernate proxies we run into this exception:
Code:
java.lang.ClassCastException: com.blah.domain.stuff.ISomething_$$_javassist_40
at com.blah.web.inbox.SomeClass.someMethod(SomeClass.java:40)
at ....
This particular issue has been documented/discussed. But the specific confusion point for us was that we ONLY run into this when we use the newer iteration syntax, like:
Code:
for(IObject io : objects) {
...
}
If we simply change the above code to:
Code:
Iterator<IObject> it = objects.iterator();
while( it.hasNext() ) {
IObject io = it.next();
...
}
..we don't get the exception any more! Is there some documented incompatibility between the iterator-style and javassist/hibernate?
We're on Hibernate 3.2.1 and javassist 3.8.1 (the latest), and Java 5/Tomcat 5.5.
Just wondering, since this is confounding. We've managed to "fix" it by using the old-style iteration, but are not sure if this is a fix or a symptom workaround.
Thanks.
Hrishi.