Hibernate or JPA Annotation中BLOBCLOB注解写法

Posted liguangsunls

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hibernate or JPA Annotation中BLOBCLOB注解写法相关的知识,希望对你有一定的参考价值。

   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}获取就可以!

























以上是关于Hibernate or JPA Annotation中BLOBCLOB注解写法的主要内容,如果未能解决你的问题,请参考以下文章