近日程序的数据库转为oracle 在操作blob类型时报以下错误:不允许的操作: streams type cannot be used in batching。经过查找多方面的资料查证Oracle JDBC不允许流操作以批量方式执行(Oracle CLOB采用流机制作为数据读写方式)。 只需在spring配置文件中更改hibernate jdbc.batch_size为0即可。
- <bean id="oracleSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <property name="dataSource">
- <ref bean="oracleDataSource"/>
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
- <prop key="connection.provider_class">
- org.hibernate.connection.C3P0ConnectionProvider
- </prop>
- <prop key="hibernate.show_sql">true</prop>
- <prop key="hibernate.cache.use_query_cache">true</prop>
- <prop key="hibernate.cache.provider_class">
- org.hibernate.cache.EhCacheProvider
- </prop>
- <prop key="hibernate.jdbc.batch_size">0</prop>
- </props>
- </property>
<bean id="oracleSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="oracleDataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="connection.provider_class">
org.hibernate.connection.C3P0ConnectionProvider
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.jdbc.batch_size">0</prop>
</props>
</property>