spring+hibernate將Oracle中Clob字段映射爲String類型方法:java
2、利用hibernate配置spring
<property name="hibernate.connection.SetBigStringTryClob">true</property>
2、利用hibernate註解session
@Lob @Basic(fetch = FetchType.EAGER) @Column(name="REMARK", columnDefinition="CLOB", nullable=true)
3、利用spring進行映射
app
1.在applicationContext.xml中加入如下代碼:fetch
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" lazy-init="true"> </bean> <bean id="lobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler" lazy-init="true"> <property name="nativeJdbcExtractor" ref="nativeJdbcExtractor" /> </bean> 在<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">段中加入: <property name="lobHandler" ref="lobHandler" />
2.在映射文件中映射Clob字段,如:hibernate
<property name="assessorId" type="org.springframework.orm.hibernate3.support.ClobStringType"/>
3.在實體中定義屬性code
private String assessorId;