Home  >  Article  >  Database  >  对Oracle的大数据类型CLOB字段进行插入操作

对Oracle的大数据类型CLOB字段进行插入操作

WBOY
WBOYOriginal
2016-06-07 17:00:351429browse

大家可能已经注意到 nativeJdbcExtractor和 lobHandler 都设置为 lazy-init=quot;truequot;,这是因为 nativeJdbcExtractor需要

1.spring配置:

class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor"
  lazy-init="true" />
 ?tid=12" target="_blank" title="Oracle">OracleLobHandler"
  lazy-init="true">
 
  
 


   
   
       

 
  
    classpath:/com/ffcs/crm/models
  

 

       
           
                org.hibernate.dialect.Oracle9Dialect
                true 'Y', false 'N'
                true
                false
           

       

   


2.Hibernate映射文件配置:

           
        type="org.springframework.orm.hibernate3.support.ClobStringType"
        column="CONTENT"
        length="4000"
    >

可用@Lob
 


3.PO的seter/geter:

private String content;
public String getContent() {
  return content;
}
public void setContent(String content) {
  this.content = content;
}


4.在service层我们就可以直接将VO的content直接set进PO就OK,跟一般数据类型一样处理。
OK了!
是不是很简单?之前一直在寻找hibernate 对CLOB的支持,试过很多方法后都没有成功,后来发现spring竟然对LOB有很好的支持。

/http://blog.sina.com.cn/s/blog_727f38e60100ofrs.html转自此处

//

大家可能已经注意到 nativeJdbcExtractor和 lobHandler 都设置为 lazy-init="true",,这是因为 nativeJdbcExtractor需要通过运行期的反射机制获取底层的 JDBC 对象,所以需要避免在 Spring 容器启动时就实例化这两个 Bean。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn