oracle中clob字段的使用

时间:2022-10-09 15:52:59

oracle中定义了一个字段是clob的,由于用的是ssh的框架,结果在面向对象存取的时候出现clob类型字段和String类型字段的转换问题。开始查阅了clob字段和String字段的相互转换的方法进行处理结果在运行的时候出现can not reset reader的问题,查了百度,但还是没解决,也许是运行环境不同。后来就使用了另外一种方法:

一:在hibernate.cfg.xml文件中加一个property属性标签

<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@17*.1*8.1.7*:1521:orcl</property>
<property name="hibernate.connection.username">bb</property>
<property name="hibernate.connection.password">bb</property>
<property name="hibernate.connection.SetBigStringTryClob">true</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.jdbc.batch_size">0</property>
***(此处省略其他) </session-factory>
</hibernate-configuration>

注意:只加了中间
<property name="hibernate.connection.SetBigStringTryClob">true</property>

一行,其他的不需要动

然后在实体类和实体类的映射文件中所有的clob属性皆按正常的String类型处理就可以了,不需要手工转换了

相关文章