`

hibernate操作 oracle clob字段

阅读更多
Clob content = almanacBean.getContributionContent();   
almanacBean.setContenteStr(content.getSubString(1, (int)content.length()));  


Action 层以String传过来

DAO:
public TbAlmanacContribution savaTbAlmanacContribution(final TbAlmanacContribution tbAlmanacContribution)   
2.    {   
3.        HibernateCallback callback = new HibernateCallback()   
4.        {   
5.            public Object doInHibernate(Session session) throws HibernateException, SQLException   
6.            {   
7.                 String content=tbAlmanacContribution.getContenteStr();//获取传过来的string   
8.                TbAlmanacContribution temp = tbAlmanacContribution;   
9.                temp.setContributionContent(Hibernate.createClob(" "));//首先插入一个空的clob对象   
10.                session.saveOrUpdate(temp);//保存   
11.                session.flush();   
12.                session.refresh(temp, LockMode.UPGRADE);   
13.                try  
14.                {   
15.                    SerializableClob  sc= (SerializableClob)temp.getContributionContent();//序列化成clob   
16.                    Clob wrapclob = sc.getWrappedClob();   
17.                    if(wrapclob instanceof CLOB){   
18.                        CLOB clob = (CLOB)wrapclob;   
19.//                    clob = (oracle.sql.CLOB) temp.getContributionContent();   
20.//                    clob.putString(1,content);   
21.                        java.io.Writer writer = clob.getCharacterOutputStream();   
22.                        writer.write(content);   
23.                         writer.close();   
24.                    }   
25.  
26.//                      session.saveOrUpdate(temp);   
27.//                    tx.commit();   
28.  
29.                } catch(Exception e)   
30.                {   
31.                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.   
32.                }   
33.                return temp;   
34.            }   
35.        };   
36.        return (TbAlmanacContribution) getHibernateTemplate().execute(callback);   
37.    }  

读取
分享到:
评论

相关推荐

    spring+hibernate操作oracle的clob字段

    J2EE开发中,经常会遇到存储大文本的文字信息,而oracle数据库的vachar字段最大能存储4000个字节,存储更大的信息必须使用clob或blob字段,本文档就是针对j2ee开发中对colb字段操作的实现。

    spring+hibernate 解决大字段(clob)

    是我自己验证过的 用的是oracle10数据库 文件里面有具体的配置。

    关于Oracle的 Clob数据类型在Hibernate中的应用小结

    关于Oracle的 Clob数据类型在Hibernate中的应用小结

    关于在Hibernate中对于Clob,Blob字段的处理方法

    oracle的jdbc驱动程序,用这个版本的操作Clob,blob类型的数据很方便。 博文链接:https://zhenjw.iteye.com/blog/173419

    spring+hbernate对clob、blob字段的处理

    一个完整的工程,主要功能为:spring+hbernate对clob、blob字段的处理 包括:数据脚本、典型的SSH框架处理,以及spring、hibernate数据批量保存等功能源码、所用到的lib包 数据环境为:oracle 10G 开发:Mycelipse5.1...

    ssh(structs,spring,hibernate)框架中的上传下载

    这是Hibernate3引入的新特性,对于包含重量级大数据的表字段,这种抽取方式提高了对大字段操作的灵活性,否则加载Tfile对象的结果集时如果总是返回fileContent,这种批量的数据抽取将可以引起数据库的"洪泛效应"。...

    DBKING使用指南

    在dbking中,所有的数据库数据只有五种数据类型,String、Number(BigDecimal)、Timestamp、Clob(String)、Blob(byte[]),经过反复测试后,我们会例出各种数据库数据类型到这五种类型的映射表,当然我们也有...

    Spring中文帮助文档

    11.5.3. 指定SimpleJdbcInsert所使用的字段 11.5.4. 使用SqlParameterSource提供参数值 11.5.5. 使用SimpleJdbcCall调用存储过程 11.5.6. 声明SimpleJdbcCall使用的参数 11.5.7. 如何定义SqlParameters 11.5.8....

    Spring API

    11.5.3. 指定SimpleJdbcInsert所使用的字段 11.5.4. 使用SqlParameterSource提供参数值 11.5.5. 使用SimpleJdbcCall调用存储过程 11.5.6. 声明SimpleJdbcCall使用的参数 11.5.7. 如何定义SqlParameters 11.5.8....

Global site tag (gtag.js) - Google Analytics