@Test
public void testWriteBlob() throws Exception
{
//创建学生对象
Students s= new Students(1,"张三丰","男",new Date(),"武当山");
//获得照片文件
File f= new File("img"+File.separator+"cat.jpg");
//获得照片文件的输入流
InputStream input = new FileInputStream(f);
//创建一个Blob对象
Blob image = Hibernate.getLobCreator(session).createBlob(input,input.available());
s.setPicture(image);
session.save(s);
}
添加回答
举报
0/150
提交
取消