-->
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.  [ 3 posts ] 
Author Message
 Post subject: CLOBs
PostPosted: Tue Oct 06, 2009 4:59 pm 
Newbie

Joined: Tue Sep 09, 2008 12:19 pm
Posts: 10
Hi All,
I'm having some problems with CLOBs
I'm trying to write a String message into the CLOB. (Oracle)
e.g.
Code:
Record r = new Record();
r.setSomeString(Hibernate.createClob(someString));

This won't compile because method setSomeString(CLOB) in the type Record is not applicable for the arguments (Clob)
BTW, setSomeString(CLOB) takes an argument of type oracle.sql.CLOB
OK fine, so I did a cast like this:
Code:
r.setSomeString((oracle.sql.CLOB) Hibernate.createClob(someString));

At run time however, this will throw an exception with the following message:
Code:
java.lang.ClassCastException: org.hibernate.lob.SerializableClob cannot be cast to oracle.sql.CLOB

My question is: How do I write a String into the CLOB?
Any suggestions?
Thanks


Top
 Profile  
 
 Post subject: Re: CLOBs
PostPosted: Tue Oct 06, 2009 5:59 pm 
Newbie

Joined: Tue Sep 09, 2008 12:19 pm
Posts: 10
I got it to work. (with some help from my smart friends)
Evidently all I had to do is to leave my setSomeString(String s) and getSomeString() methods alone...
meaning that they don't need to take an argument of type CLOB or return a CLOB.
My configuration file need to specify the type="text"
For example:
<property name="someString" type="text">
<column name="SOMESTRING" />
</property>

The type="text" will do the trick of converting the huge piece of text (some string) and write it to the CLOB in the Oracle DB.
This was what I was after so it worked for me.
If this also helps you; Great....
G'day to all,


Top
 Profile  
 
 Post subject: Re: CLOBs
PostPosted: Sun Nov 10, 2013 3:39 am 
Newbie

Joined: Sun Nov 10, 2013 3:36 am
Posts: 1
simple but very much useful information otherwise it would have been much difficult
Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.