java對象存儲到blob
bytearrayoutputstream bo = new bytearrayoutputstream();
objectoutputstream oo;
try {
oo = new objectoutputstream(bo);
oo.writeobject(libraryetextjn);
} catch (ioexception e) {
e.printstacktrace();
}
blob blob= hibernate.createblob(bo.tobytearray());
從blob讀取java對象
objectinputstream is = new objectinputstream(new bufferedinputstream(blob.getbinarystream()));
libraryetext libraryetext = (libraryetext)is.readobject();
hibernate配置blob字段
<property name="liberary" column="liberary" type="blob" />
最新内容請見作者的github頁:http://qaseven.github.io/