读书人

大文本字段投射

发布时间: 2013-11-08 17:52:14 作者: rapoo

大文本字段映射

?

想通过jpa映射大文本字段到数据库的时候需要加@Lob

且实体类不同的类型对应数据库不同的字段类型,每种数据库各不相同具体情况可以参照如下方式进行验证。

?

? // 测试字段1
??? private String bigText;
???
??? // 测试字段2
??? private Byte[] fileText;

??? @Lob
??? public Byte[] getFileText() {
??? ??? return fileText;
??? }

??? public void setFileText(Byte[] fileText) {
??? ??? this.fileText = fileText;
??? }

??? @Lob
??? public String getBigText() {
??? ??? return bigText;
??? }

??? public void setBigText(String bigText) {
??? ??? this.bigText = bigText;
??? }

读书人网 >编程

热点推荐