Thread:
 ClassCastException using Hibernate2 Blobs 
 dannwebster   25 Mar 2004, 01:15 
 Re: ClassCastException using Hibernate2 Blobs 
 dannwebster   26 Mar 2004, 19:23 
 Re: ClassCastException using Hibernate2 Blob... 
 leenamba   30 Mar 2004, 11:21 
 Re: ClassCastException using Hibernate2 B... 
 alu1344   08 Jun 2004, 09:20 
 Re: ClassCastException using Hibernate2 Blobs 
 zetacode   21 Nov 2006, 11:09 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: dannwebster (26 Mar 2004, 19:23) Replies: 2, Views: 40503
Subject: Re: ClassCastException using Hibernate2 Blobs
From above:

<snip>
This code always throws a ClassCastException on this line:

<code>
oracle.sql.BLOB blob = (oracle.sql.BLOB) foo.getBlob();
</code>

When hibernate gets the Blob, it is of type
net.sf.hibernate.lob.BlobImpl, which is not castable to oracle.sql.BLOB.
Since BlobImpl is what Hibernate uses to implement any type which is
generated using a "blob" type in the .hbm.xml file, and it makes sense
that it is not a subclass of oracle.sql.BLOB. 

</snip>

This problem is actually simply because the offending foo was part of a
lazy-loaded object fetched as part of a collection. It goes away if the
object itself is refreshed, or if Hibernate.initialize() is called on
the collection that foo is part of.
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]