-->
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.  [ 9 posts ] 
Author Message
 Post subject: Problem in retrieving Clob data
PostPosted: Thu Dec 08, 2005 7:45 am 
Newbie

Joined: Thu Dec 08, 2005 7:30 am
Posts: 7
Hibernate version:3

Mapping resource entry as follows:

<property
name="copyText"
update="true"
insert="true"
column="COPY_TEXT"
type="oracle.sql.CLOB"
/>


Problem in retrieving Clob type data from oracle 10g. using hibernate3.Always it is returning null even though the data is present.The data which is present in data base is not too lengthy. It is just three lines text.

The code which I used is:

public Object nullSafeGet(ItemCopyV copy)throws HibernateException,SQLException{

Clob clob=copy.getCopyText();

return (clob==null? null :clob.getSubString(1, (int) clob.length()));

}

Please help me to solve this...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 8:03 am 
Beginner
Beginner

Joined: Tue Jul 19, 2005 5:08 am
Posts: 26
Location: Germany
we are using java.sql.Clob instead of the oracle´s Clob. maybe you should try that one.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 8:05 am 
Newbie

Joined: Thu Dec 08, 2005 7:30 am
Posts: 7
Hi thanks for ur reply.

I tried java.sql.Clob too. still i am getting only null as result.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 8:15 am 
Newbie

Joined: Sun Nov 21, 2004 5:21 am
Posts: 14
the mapping type should be "clob"as follow:
<property
name="copyText"
update="true"
insert="true"
column="COPY_TEXT"
type="clob"
/>

we have the same problem with oracle. as a work around we use this code:
Code:
    myData.setClobField(Hibernate.createClob(" "));
    session.save(myData);// this will set the none clob fields
    session.flush();
    session.refresh(myData, LockMode.READ); //grabs an Oracle CLOB
    oracle.sql.CLOB clob = (oracle.sql.CLOB) ((SerializableClob)myData.getClonField()).getWrappedClob();
    java.io.Writer pw = clob.getCharacterOutputStream();
    pw.write(someXmlRepresentation);
    pw.close();


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 8:44 am 
Newbie

Joined: Thu Dec 08, 2005 7:30 am
Posts: 7
Hi glim,

I am getting NullPointerException while calling the method which contains the code that you have provided.

but data is present in data base.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 9:51 am 
Newbie

Joined: Sun Nov 21, 2004 5:21 am
Posts: 14
can you show the relevant code and stack strace?

which line gave the NullPointerException?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 09, 2005 2:02 am 
Newbie

Joined: Thu Dec 08, 2005 7:30 am
Posts: 7
hi glim,

while executing the following statement i am getting null pointer exception

Clob clob=copy.getCopyText();

Hibernate: select pcitemcopy0_.ITEM_COPY_ID as ITEM1_, pcitemcopy0_.END_DATE_ACTIVE as END11_0_, pcitemcopy0_.COPY_TYPE as COPY12_0_, pcitemcopy0_.COPY_TEXT as COPY13_0_ from PC_ITEM_COPY_V pcitemcopy0_ where pcitemcopy0_.ITEM_COPY_ID=173

java.lang.NullPointerException
at sample.PersistenceHandler.retrieveData(PersistenceHandler.java:83)
at sample.PersistenceHandler.main(PersistenceHandler.java:55)
Process exited with exit code 0.


and the thing is all the other column values i am able to retrieve.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 09, 2005 5:58 am 
Newbie

Joined: Thu Dec 08, 2005 7:30 am
Posts: 7
hi

I am using oracle thin client......is that the problem .....


is it not possible to access Clob values using thin client....


Top
 Profile  
 
 Post subject: No, it's not that
PostPosted: Sun Dec 11, 2005 3:14 am 
Newbie

Joined: Sun Nov 21, 2004 5:21 am
Posts: 14
we're using thin client as well.

do you realy need clob? can you use "long" instead? it is working much better...


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