其实上传图片等保存到oracle的blob字段的话,感觉不是太好,但如果一定要这样做的话也是可以的,

比如struts1+hibernate上传一个文件,典型的示例代码如下:
   

 

 DWorkstationDAO d=new DWorkstationDAO();
  Session s = d.getSession();

FormFile file1 = f.getFile(); 

byte[] b=file1.getFileData();
   ByteArrayInputStream imgin = new ByteArrayInputStream(b);
   o.setPic(Hibernate
     .createBlob(ImageUtil.genSmallImg(imgin))); 
      d.save(o);

其中ImageUtil.genSmallImg(imgin)是一个保存缩略图的方法,

更新的时候:

 o.setPic(Hibernate.createBlob(new byte[1]));
   s.flush();
   s.refresh(o,LockMode.UPGRADE);
      byte[] b= file1.getFileData();
     Blob ph= Hibernate.createBlob(b);//数据转换为blob类型

   o.setPic(ph);