现在的位置: 首页 > 综合 > 正文

在spring+ hibernate+ tapestry开发框架中处理orcale blob字段内容

2013年08月21日 ⁄ 综合 ⁄ 共 719字 ⁄ 字号 评论关闭

时下spring+ hibernate+ tapestry 是一个新的流行的JAVA 开发框架.本文提供一个在此开发框架下处理orcale blob字段内容的例子:

orcale blob数据库在hibernate中的映射为    private byte[] zp;///照片     "zp"         BLOB,此用来存放员工的照片.

 /**@hibernate.property
     *  column = "ZP"
     *  type = "byte[]"
     *  not-null = "false"
     *  unique = "false"
  *  lazy = "false" 
  *   @return
    **/
    public byte[] getZp() {
  return zp;
 }
 public void setZp(byte[] zp) {
  this.zp = zp;
 }

使用typestry的upload控件上传图片文件,并保存到orcale blob字段zp中.

public abstract IUploadFile getFile();

private void uploadFile() throws Exception {
  if (StringUtils.isBlank(getFile().getFileName())) {
   // throw new PddtRunException("请选择上传文件");
  } else {
   byte bt[] = new byte[(int) getFile().getSize()];
   getFile().getStream().read(bt);
   ((YgBo) getItem()).setZp(bt);

  }
 }

最后保存YgBo.

 

抱歉!评论已关闭.