-->
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.  [ 2 posts ] 
Author Message
 Post subject: Getting a CharacterStream to write to a Clob
PostPosted: Tue Dec 16, 2003 2:44 pm 
Newbie

Joined: Tue Dec 16, 2003 2:29 pm
Posts: 1
Location: Salt Lake City, UT
I am trying to figure out how to use the sample code to get a character stream to write to a Clob field via Hibernate. I have looked at the sample code given on this site.
http://www.hibernate.org/Documentation/UsingClobsWithOracleAndHibernate12

...but I get a ClassCastException when it tries to cast a java.sql.Clob to a oracle.sql.CLOB. What am I doing wrong?

Here is a snippet from my code...

Code:
submData.setData(Hibernate.createClob(" "));
    try {
      session.refresh(submData, LockMode.UPGRADE); //grabs an Oracle CLOB
      oracle.sql.CLOB clob = (oracle.sql.CLOB) submData.getData();
      return clob.getCharacterOutputStream();
    }
    catch (HibernateException ex) {
      throw new DataAccessException(ex);
    }
    catch (SQLException ex) {
      throw new DataAccessException(ex);
    }


submData is a class that contains a java.sql.Clob field. getData/setData() are the get/setters for subm's Clob field. They return a java.sql.Clob field. The data field is mapped in a Hibernate mapping field like this...

Code:
   <property name="data" type="clob" column="DATA"/>


The ClassCastExceptin occurs on the line that gets submData's Data field (java.sql.Clob) and attempts to cast it to a oracle.sql.CLOB.

How do I get around that ClassCastException? I assume I am doing something wrong. Is there another way to get a Writer to the clob field?

-Greg


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 12, 2004 11:04 am 
Newbie

Joined: Fri Oct 17, 2003 5:09 am
Posts: 13
Location: Madrid, Espa
Hello,

if you are using tomcat, i resolved this deleting the drivers of oracle (ojdbc14_g.jar) from WEB-INF/lib, and move to TOMCAT_HOME/common/lib.


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

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.