Hello!
I have take a look into the handling of clobs in oracle 9 and found the following:
If you do have a clob in the database, and use setString on the JDBC-Statement it will work as long as the string is less than 4000 chars.
The database automatically wraps it in an clob.
setString fails only if you use a string longer than that.
The oracle jdbc driver force us to use the clob stuff (a shame)
However, i thought:
If one use setString with an longer string - the field in the database must be a clob - and so i could do this transparently by wrapping the whole oracle driver and override the setString function.
getString in the ResultSet uses the ResultSetMetadata to decide if getClob should be used instead.
In the case of setString - I use the createTemporary function and store a reference to the clob. If the statement gets closed, i will free them.
So no need to have a listener or any special string-type in hibernate anymore.
It is completely transparent.
For sure, this is currently not in use in an real-live application and i might have overseen something, but give it a try:
http://www.l3x.net/~im/JdbcOraWrapper.zip
Inside the zip you will find a jar (the precompiled oracle wrapper) and the source for all this.
Simply place the JdbcOraWrapper.jar and the oracle jdbc driver in your classpath.
Use "JdbcOraWrapperDriver" as your new Oracle driver and change the
url to jdbc:oracle
_clob:thin:.....
(ok - this is not "transparent" but allows you to use both drivers at the same time :-)