Duffblog

          前進一步,看看,需要前進更大一步才可以。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            5 隨筆 :: 53 文章 :: 5 評論 :: 0 Trackbacks
          public AttachmentFile addAttachmentFile(AttachmentFile attachmentFile) {
          ??try {
          ???attachmentFile.setAttachmentFileBlob(BLOB.empty_lob());
          ??} catch (SQLException e) {
          ???e.printStackTrace();
          ??}
          ??AttachmentFile savedAttachmentFile = (AttachmentFile)super.saveObject(attachmentFile);
          ??getHibernateSession().flush();
          ??return (AttachmentFile) updateAttachmentFileBlob(savedAttachmentFile);
          ?}

          public AttachmentFile updateAttachmentFileBlob(AttachmentFile attachmentFile) {
          ??//Connection jdbcConnection = this.getHibernateSession().connection();
          ??
          ??if (attachmentFile.getAttachmentFile() != null){
          ???
          ???getHibernateSession().refresh(attachmentFile, LockMode.UPGRADE);
          ???Blob sqlBlob = attachmentFile.getAttachmentFileBlob();
          ???org.hibernate.lob.SerializableBlob hbmBlob = (org.hibernate.lob.SerializableBlob)sqlBlob;
          ???BLOB oracleBlob = (BLOB)hbmBlob.getWrappedBlob();
          ???OutputStream os;
          ???try {
          ????os = oracleBlob.getBinaryOutputStream();
          ????os.write(attachmentFile.getAttachmentFile());
          ????os.close();
          ???} catch (Exception e1) {
          ????throw new? SystemRuntimeException(e1.getMessage(),e1);
          ???}
          ??}

          對了Blob和Clob,需要先save一個空的Blob(Clob),然后,在update.
          posted on 2006-11-03 20:07 追球者 閱讀(696) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 陆河县| 颍上县| 拉萨市| 长垣县| 牡丹江市| 河西区| 繁昌县| 石棉县| 紫云| 奈曼旗| 富裕县| 锡林郭勒盟| 陆川县| 开封市| 密山市| 泰兴市| 景宁| 临江市| 张北县| 达孜县| 金华市| 和林格尔县| 嘉义县| 乐东| 随州市| 汪清县| 拉萨市| 曲阳县| 綦江县| 交口县| 庆云县| 洛南县| 永嘉县| 湘潭市| 麻栗坡县| 伊金霍洛旗| 隆安县| 惠州市| 稻城县| 云安县| 马龙县|