public class BlobDao {
public int saveBlob(User user,String imagePath) throws IOException{
//读取图片的二进制数据
InputStream in = this.getClass().getResourceAsStream(imagePath);
byte[] buffer = new byte[in.available()];
in.read(buffer);
in.close();
user.setImage(Hibernate.createBlob(buffer));
tran=session.biginTransaction();
tran.commit();
return user.getId();
}