用hibernate封装oracle的clob类型操作起来很不方便,但是新的oracle10g的jdbc驱动,对此有很多改进。
环境 :wodows2000、oracle9.2、oracle10gJDBC驱动(必须)、hibernate3.1.2
建表脚本:
/*==============================================================*/
/* Table: StoreFile */
/*==============================================================*/
create table StoreFile (
uuid VARCHAR2(128) not null,
name VARCHAR2(200),
text CLOB,
constraint PK_STOREFILE primary key (uuid)
);
本文来自CSDN博客,转载请标明出处:
hibernate.cfg.xml:(注意多了个SetBigStringTryClob设置,其它没有什么特殊的了)
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">java</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@10.128.4.69:1521:kf</property>
<property name="hibernate.connection.username">java</property>
<property name="hibernate.connection.SetBigStringTryClob">true</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<mapping resource="com/study/database/hb/map/File.hbm.xml"/>
</session-factory>
</hibernate-configuration>
//比以前特殊的地方是hibernate.cfg.xml多了个SetBigStringTryClob设置。
//把clob映射成string类型,这样在多过4000个字符时也不会出错了。操作方法和普通的string类型一样。