<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">和大家分享下如何处理BLOB存取,此类来源于Mybatis官方文档,网上有许多方法,但是都感觉用起来很不顺手,解决方法不如官方文档明白清楚。</span>
先建一个实体类BlobRecord.java
package org.apache.ibatis.submitted.blobtest;
public class BlobRecord {
private int id;
private byte[] blob;
public BlobRecord(int id, byte[] blob) {
super();
this.id = id;
this.blob = blob;
}
public BlobRecord(int id, Byte[] blob) {
super();
this.id = id;
final byte[] newBytes = new byte[blob.length];
for (int i = 0; i < blob.length; i++) {
Byte b = blob[i];
newBytes[i] = b;
}
this.blob = newBytes;
}
public int getId() {
return id;
}
public byte[] getBlob