日期:2014-05-17  浏览次数:20867 次

Hibernate点不出createBlob()方法是怎么回事
我在练习用hibernate将图片保存到oracle数据库中这有其中一部分代码
public int saveB(Login login,String imagename) throws IOException {
//创建读取图片的输入流
InputStream in=this.getClass().getResourceAsStream(imagename);
//将输入流字符保存在字符数组中,数组长度就是输入流读取的字符长度
byte[] buffer=new byte[in.available()];
//调用输入流的read方法将数据读取到buffer中
in.read(buffer);
//关闭输入流
in.close();
//将buffer赋给login的image属性 image 为blob类型
login.setImage(Hibernate.createBlob());
}
最后一行的.createBlob()提示错误The method createBlob() is undefined for the type Hibernate

不知道是怎么回事......是缺少jar吗?求高手指点
------解决方案--------------------
我用的是hibernate4不知道和这个有没有关系
------解决方案--------------------
我也正遇到这个问题,这个方法是hibernate3里面的,hibernate4里面没有这个方法了!但是不知道被谁代替了!
------解决方案--------------------
用LobHelper的实例对象可以实现.getLobHelper().createBlob方法 但我用着方法保存Blob类型图片到oracle中时 数据是损坏的  不知道为什么