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?

Gavin

> -----Original Message-----
> From: Ugo Cei [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, 1 January 2003 3:22 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [Hibernate] Using CLOBs
> 
> 
> 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(DBDataSetI
> mpl.java:2461)
>          at 
> oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePrepa
> redStatement.java:1155)
>          at 
> oracle.jdbc.driver.OraclePreparedStatement.setString(OraclePre
> paredStatement.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
> 


********** CAUTION - Disclaimer **********
This message may contain privileged and confidential
information. If you are not the intended recipient of this
message (or responsible for delivery of the message to
such person) you are hereby notified that any use,
dissemination, distribution or reproduction of this message
is prohibited. If you have received this message in error,
you should destroy it and kindly notify the sender by reply
e-mail. Please advise immediately if you or your employer
do not consent to Internet e-mail for messages of this kind.
Opinions, conclusions and other information in this
message that do not relate to the official business of
Expert Information Services Pty Ltd ("The Company")
shall be understood as neither given nor endorsed by it.

The Company advises that this e-mail and any attached
files should be scanned to detect viruses. The Company
accepts no liability for loss or damage (whether caused
by negligence or not) resulting from the use of any
attached files.
**EIS******** End of Disclaimer **********



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