-->
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.  [ 6 posts ] 
Author Message
 Post subject: CLOB and 4K limit with Oracle
PostPosted: Sun Nov 16, 2003 1:50 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Hi

I'm using a lot of CLOB values in my application. I have a problem that values that are bigger than 4K are not inserted in the Oracle Database, the row is inserted but there is no value in the CLOB column. What is the best way to persist CLOB values?.

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 16, 2003 2:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
http://www.hibernate.org/Documentation/ ... ibernate12

Code:
Session s = sf.openSession();
tx = s.beginTransaction();
foo = new Foo();
foo.setClob( Hibernate.createClob(" ") );
s.save(foo);
s.flush();
s.refresh(foo, LockMode.UPGRADE); //grabs an Oracle CLOB
oracle.sql.CLOB clob = (oracle.sql.CLOB) foo.getClob();
java.io.Writer pw = clob.getCharacterOutputStream();
pw.write(content);
pw.close();
tx.commit();
s.close();


Top
 Profile  
 
 Post subject: CLOB and BLOBs are set to null after I load another object
PostPosted: Tue Nov 18, 2003 5:16 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Hi

Thanks for the reply

Using the code my CLOBs and BLOBs are being stored in the database perfectly and are queried correctly. If I create another session using the same SessionFactory and manipulate another object my CLOB and BLOBs are set to null in the database. I put a trace in the getBlob code and Hibernate is accesing the method when I load the other object. If Hibernate tries to persist the Object associated with the CLOB or BLOB without using the code above then the database columns are set to null because of the 4K problem.


Top
 Profile  
 
 Post subject: Got it
PostPosted: Tue Nov 18, 2003 9:12 pm 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Ok, the values were being set to null when Hibernate flushed the session cache to the database in a load operation. So what I did to correct this problem was to use evict on the object after saving it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 9:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
sorry? Hibernate does not flush() from load(). And why would a flush() set anything to null? Do you have a broken get/set pair?


Top
 Profile  
 
 Post subject: Load
PostPosted: Wed Nov 19, 2003 10:10 am 
Regular
Regular

Joined: Sun Oct 26, 2003 9:02 pm
Posts: 90
Hi

You're right. This happened while I was saving the other object. Hibernate detected that the object associated with the BLOB was modified and it persisted it. That is why I had to do the evict.


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