i use hibernate to insert string to a clob column,when string length between 1000~2000 there is some errors,the string can't be inserted in to the database , but i use jdbc+c3p0(not use hibernate) every thing is ok. so i am sure this is hibernate's bug.any body can help me !!!!!!!!!!!!!!!!!!!!!!!!!!
there is the orace example :
http://www.oracle.com/technology/sample_code/tech/java/codesnippet/jdbc/clob10g/ClobManipulationIn10g.java.html
Hibernate version:
version:3.1.3 and 3.2.*
Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.trundle.cms.po">
<class name="Clob" table="clob_tab" lazy="false">
<id column="id" length="32" name="id" type="string">
<generator class="uuid.hex"/>
</id>
<!--in database i use Clob type not varchar-->
<property name="clob" column="clob_col" type="string" />
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Code:
org.hibernate.Session session = org.trundle.cms.db.HibernateUtil.getNewSession();
org.hibernate.Transaction t = session.beginTransaction();
org.trundle.cms.po.Clob po = new org.trundle.cms.po.Clob();
po.setClob(MyExample.readFile());[b][color=blue]//file length is 1115 byte[/color][/b]
session.save(po);
session.flush();
t.commit();
session.close();
Full stack trace of any exception that occurs:Code:
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.trundle.test.ClobManipulationIn10g.main(ClobManipulationIn10g.java:228)
[color=red]Caused by: java.sql.BatchUpdateException: ORA-01461: can bind a LONG value only for insert into a LONG column[/color]
at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:343)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10698)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
... 6 more
Name and version of the database you are using:
oracle10g use release2 ojdbc4.jar
The generated SQL (show_sql=true):
Hibernate: insert into clob_tab (clob_col, id) values (?, ?)
Debug level Hibernate log excerpt:
info