Hibernate Spring中使用Oracle clob类型
Hibernate Spring中使用Oracle clob类型
Oracle数据库中,较大内容varchar2(4000)往往也很无奈。对此,我们往往采用大对象进行存储(clob),但是由于jdbc驱动对CLOB支持不好,因此使用hibernate进行操作时,往往非常麻烦。但是使用最新的oracle驱动,ojdbc14.jar
然后稍微更改Spring中,SessionFactory的属性参数:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
</props>
</property>
<property name="mappingResources">
</property>
</bean>
然后将映射文件中更改成:
<property name="newsContent" type="text">
<column name="NEWS_CONTENT" />
</property>
在POJO类中,直接使用String类型,就可以自由访问了!
评论暂时关闭