Hibernate Spring中使用Oracle clob類型

來源:互聯網
上載者:User

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類型,就可以自由訪問了!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.