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. |