Duffblog

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

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 礼泉县| 宁化县| 武宁县| 尼玛县| 惠来县| 灵璧县| 香港 | 南溪县| 星座| 永州市| 海阳市| 禄丰县| 宕昌县| 公安县| 泾源县| 南宫市| 阿图什市| 赤壁市| 谢通门县| 云南省| 通渭县| 镇远县| 封开县| 桑植县| 南昌市| 图们市| 长春市| 天长市| 正镶白旗| 元朗区| 大石桥市| 花莲县| 贺州市| 台州市| 丰原市| 茌平县| 祁东县| 礼泉县| 交口县| 兰考县| 沙坪坝区|