本人现在做的是操作 oracle 10g clob类型字段
contentdetail clob not null,
在hibernate中配置为
- XML code
<property name="contentdetail" type="org.springframework.orm.hibernate3.support.ClobStringType"> <column name="CONTENTDETAIL" not-null="true" /> </property>
applicationContext.xml
- XML code
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd" default-autowire="byName"> <!-- 注入 --> <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"> <property name="nativeJdbcExtractor"><ref local="nativeJdbcExtractor"/></property> </bean> <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"> </property> <property name="url" value="jdbc:oracle:thin:@192.168.168.227:1521:orcl"> </property> <property name="username" value="pdyg"></property> <property name="password" value="pdyg"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <!-- 引用 --> <property name="lobHandler"> <ref bean="oracleLobHandler" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.Oracle9Dialect </prop> <prop key="hibernate.show_sql"> true </prop> <prop key="hibernate.format_sql"> true </prop> <prop key="current_session_context_class">true</prop> <prop key="hibernate.connection.SetBigStringTryClob"></prop> <prop key="hibernate.jdbc.batch_size">0</prop> </props> </property> <property name="mappingResources"> <list> <value>com/bsth/pdyg/domain/Friendlink.hbm.xml</value> <value>com/bsth/pdyg/domain/Userinfo.hbm.xml</value> <value>com/bsth/pdyg/domain/Contentinfo.hbm.xml</value> <value>com/bsth/pdyg/domain/Filemanager.hbm.xml</value> <value>com/bsth/pdyg/domain/Email.hbm.xml</value></list> </property> </bean> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="serviceMethod" expression="execution(* com.bsth.pdyg.service.*.*(..))" /> <aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" /> </aop:config> <!-- 导入 --> <import resource="frontend.xml"/> <import resource="backend.xml"/> </beans>