如何储存blob对象在sql server?实体set blob对象保存就报错,不set blob对象就没问题
@Test
public void writeBlob() throws Exception{
Students s=new Students(1, "张学友", "男", new Date(), "香港");
File file=new File("d:"+File.separator+"boy.jpg");
InputStream is=new FileInputStream(file);
Blob img=Hibernate.getLobCreator(session).createBlob(is, is.available());
s.setPicture(img);
session.save(s);
}一月 05, 2017 3:03:04 下午 org.hibernate.AssertionFailure <init>
ERROR: HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: null id in hibernate_test01.Students entry (don't flush the Session after an exception occurs)