Gavin King wrote:
The name of the type is "clob", and the expected property type
is java.sql.Clob. Note that there are restrictions upon what
you can do with Clobs (they can't be used outside of transaction,
for example).

You should also take notice of Hibernate.createClob().

Thanks. Everything works fine ... at least in theory ...


If you use Oracle 8i and try to store more than 4000 characters, this is what you get:

java.sql.SQLException: Data size bigger than max size for this type: 7894
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:147)
at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2461)
at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1155)
at oracle.jdbc.driver.OraclePreparedStatement.setString(OraclePreparedStatement.java:1572)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:217)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:217)
at cirrus.hibernate.type.ClobType.set(ClobType.java:14)


Actually, having already been through the nightmare that CLOB support in Oracle is, I expected nothing more and nothing less.

AFAIK there is just one way to store more than 4000 characters in an Oracle CLOB via JDBC:

- start a transaction
- insert into tablename(id, clob_field) values('X', empty_clob())
- select clob_field from tablename where id = 'X' for update of clob_field
- ResultSet rs = (oracle.jdbc.driver.OracleResultSet) ps.executeQuery();
  if (rs.next()) {
    oracle.sql.CLOB clob = rs.getCLOB(1);
    java.io.Writer pw = clob.getCharacterOutputStream();
    pw.write(content);
    pw.close();
  }
- commit

If this isn't a PITA, I don't know what is :-(

Do you think it's going to be difficult to implement this rigamarole in Hibernate?

Ugo

--
Ugo Cei - http://www.beblogging.com/blog/



-------------------------------------------------------
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