飞艳小屋

程序--人生--哲学___________________欢迎艳儿的加入

BlogJava 首页 新随笔 联系 聚合 管理
  52 Posts :: 175 Stories :: 107 Comments :: 0 Trackbacks

关于hibernate中保存Blob数据的问题

你可以跟踪一下程序,看看到//2的位置时,取出的pic.getRawstream()是什么类型

pic.getRawstream()的类型是org.hibernate.lob.SerializableBlob

(oracle.sql.BLOB) 那你用这个转型肯定会ClassCastException

你查一下SerializableBlob的API,看看这个有没有其他的转换方法

oracle.sql.BLOB blob = (org.hibernate.lob.SerializableBlob)pic.getRawstream();//2
OutputStream os = blob.setBinaryStream(long pos);

SerializableBlob的setBinaryStream(long pos) 方法就是返回你所需要的OutputStream

但是这个long参数不知道该传什么,API上没有明确指明


http://www.hibernate.org/hib_docs/v3/api/org/hibernate/lob/SerializableBlob.html#setBinaryStream(long)

posted on 2007-03-31 21:18 天外飞仙 阅读(2129) 评论(1)  编辑  收藏 所属分类: hibernate

Feedback

# re: 关于hibernate中保存Blob数据的问题[未登录] 2010-06-02 13:51 Jessica
问题有解决吗?
我也遇到了,但是解决不了  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: