-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ClassCastException with instrumented Hibernate proxies
PostPosted: Mon Jul 28, 2008 9:11 pm 
Newbie

Joined: Thu Jul 26, 2007 1:12 pm
Posts: 2
Location: New York
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.