在hibernate 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;
}
按照以上的设置实体类的注解就搞定了。
Hibernate Annotation中BLOB、CLOB注解写法
最新推荐文章于 2021-04-04 10:04:34 发布
本文介绍在Hibernate中如何使用注解定义实体类的BLOB和CLOB类型的字段。对于BLOB类型,通过声明byte[]类型并使用@Lob、@Basic(fetch=FetchType.LAZY)及@Column(columnDefinition=BLOB)进行注解;对于CLOB类型,则声明为String类型,并使用@Lob、@Basic(fetch=FetchType.EAGER)及@Column(columnDefinition=CLOB)进行注解。
948

被折叠的 条评论
为什么被折叠?



