Gavin King wrote:
Ahhhh the > 4000 characters bit is where you start to need
the "for update" clause. We were wondering about that
earlier. I think you *could* make it work like this:

s = sf.openSession();
tx = s.beginTransaction();
foo = new Foo();
foo.setClob( Hibernate.createClob("") );
s.save(foo);
tx.commit();
s.close();

s = sf.openSession();
tx = s.beginTransaction();
foo = (Foo) s.load( Foo.class, foo.getId(), LockMode.UPGRADE );
oracle.sql.CLOB clob = (oracle.sql.CLOB) foo.getClob();
java.io.Writer pw = clob.getCharacterOutputStream();
pw.write(content);
pw.close();
tx.commit();
s.close();


Would you try that for me, please?

Tried it and it *mostly* works. The only problem seems to be that Oracle apparently does not distinguish between zero-length strings and NULL, so if you initialize the CLOB with Hibernate.createClob(""), the actual database column is nullified and the subsequent getClob() call returns null, making the clob.getCharacterOutputStream() fail with a NPE.


As a quick&dirty hack, I've changed createClob("") to createClob(" ") and everything seems to work ok. However, I was wondering if it is really necessary to open a new session. Couldn't we somehow reuse the former session?

Ugo




------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ hibernate-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/hibernate-devel



Reply via email to