1 Reply Latest reply on Aug 21, 2006 5:52 AM by Camilo Lara

    Problem using blobs with hibernate on jboss 3.2.x

    ulfreich Newbie

      Hi, I'm using hibernate 2.1.8 to persist some blobs in an oracle 9i database. For this, I implemented something similar to what says in the hibernate wiki, http://www.hibernate.org/73.html, mapping a Blob to a char[]. I tested this on Jboss 4.0.3SP1 and works perfectly, but on JBoss 3.2.8SP1 it fails. The error happens when Hibernate calls the method that converts the blob to a char[], nullSafeSet(), on the line:

      oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(
       false, oracle.sql.BLOB.DURATION_SESSION);

      In this line, a temporary oracle blob gets created from the database connection asociated to the java.sql.PreparedStatement "st" created by Hibernate. The method should receive a java.sql.Connection object and, since hibernate uses a jboss datasource, the connection's class results to be org.jboss.resource.adapter.jdbc.WrappedConnection. This caused a ClassCastException. To get it working, I had to call WrappedConnection.getUnderlyingConnection(); this returns a oracle.jdbc.OracleConnection which in turn implements java.sql.Connection, so it should be accepted. As I said before, this works on Jboss 4.x, but on Jboss 3.2.x it keeps throwing a ClassCastException!

      Does anyone know how can I get this to work on 3.2.x, since it works in later versions? Thanks!