zoukankan      html  css  js  c++  java
  • Hibernate or JPA Annotation中BLOB、CLOB注解写法

       BLOB和CLOB都是大字段类型,BLOB是按二进制字节码来存储的,而CLOB是可以直接存储字符串的。

       在hibernate or JPA Annotation中,实体BLOB、CLOB类型的注解与普通的实体属性有些不同,具体操作如下:

      BLOB类型,类型声明为byte[]:
      private byte[] content;
      注解:
      @Lob
      @Basic(fetch = FetchType.LAZY)
      @Column(name = "CONTENT", columnDefinition = "BLOB",nullable=true)
      public byte[] getContent() {
        return this.content;
      }
      public void setContent(byte[] content) {
        this.content = content;
      }
      CLOB类型,类型声明为String即可:
      private String remark;
      注解:
      @Lob
      @Basic(fetch = FetchType.EAGER)
      @Column(name="REMARK", columnDefinition="CLOB", nullable=true)
      public String getRemark() {
        return this.remark;
      }
      public void setRemark(String recvdocRemark) {
        this.remark = remark;
      }

      按照以上的设置实体类的注解就OK了。

    页面获取字段的话,用EL表达式${entity.content}获取即可!

  • 相关阅读:
    1121 Django基本
    1121 爬虫简单面条版
    1118 DOM
    1114 CSS基础
    1116 前端的练习--博客界面
    1112 前端基础之标签
    仿优酷错误
    1107 python自定义实现ORM
    cesm1_2_2在南信大大型机上的移植以及运行简单case的步骤
    ERROR:105: Unable to locate a modulefile for 'xxx'
  • 原文地址:https://www.cnblogs.com/jasontec/p/9601672.html
Copyright © 2011-2022 走看看