Spring 方式处理 Clob、Blob 大字段

3 篇文章 0 订阅
2 篇文章 0 订阅
1、在 applicationContext.xml 文件中增加如下配置:
<!-- 处理Clob大字段 -->
< bean  id =  "nativeJdbcExtractor"  class = "org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"  lazy-init =  "true" ></ bean  >
< bean  id =  "lobHandler"  class = "org.springframework.jdbc.support.lob.OracleLobHandler"  lazy-init = "true"  >
        < property  name = "nativeJdbcExtractor"  ref = "nativeJdbcExtractor"  />
</ bean >

2、在  sessionFactory 中增加如下红色字的配置:
< bean  id =  "sessionFactory"  class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean"  >
        < property  name = "dataSource"  ref = "dataSource"  />
        <!-- 处理Clob大字段 -->
        <property name="lobHandler" ref="lobHandler"/>
        < property  name = "mappingResources"  >
              < list >
                    < value >  com/test/model/Announcement.hbm.xml  </ value >
              </ list >
        </ property >

        < property  name = "hibernateProperties"  >
              < props >
                    < prop  key = "hibernate.dialect"  > $[hibernate.dialect] </  prop >
                    < prop  key = "hibernate.cache.provider_class"  > org.hibernate.cache.EhCacheProvider </  prop >
                    < prop  key = "hibernate.cache.use_query_cache"  > true </  prop >
                    < prop  key = "hibernate.show_sql"  > true </  prop >
                    < prop  key = "hibernate.bytecode.use_reflection_optimizer"  > true </  prop >
                    < prop  key = "hibernate.hbm2ddl.auto"  > $[hibernate.hbm2ddl.auto] </  prop >
              </ props >
        </ property >
</ bean >

3、Clob字段处理, *.hbm.xml 文件配置如下:
< property  name = "content"  type = "org.springframework.orm.hibernate3.support.ClobStringType"  >
     < column  name = "CONTENT"  />
</ property >
4、对应的实体类中相关的字段用String 接受

5、Blob字段处理,*.hbm.xml 文件配置如下:
<  property   name  = "content"  type  = "org.springframework.orm.hibernate3.support.BlobByteArrayType"  >
     < column  name =  "CONTENT"   />
</  property >
6、对应的实体类中相关的字段用 byte[] 数组接受


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值