Home  >  Article  >  Database  >  Oracle读取Blob数据-通过hibernate

Oracle读取Blob数据-通过hibernate

WBOY
WBOYOriginal
2016-06-07 17:03:271080browse

通过hibernate向Oracle存储字节类型的数据(如byte[]等),在定义实体对象的时候不能用quot;private byte[] contentquot;, 这样定

通过hibernate向Oracle存储字节类型的数据(如byte[]等),在定义实体对象的时候不能用"private byte[] content", 这样定义我试过,在存储数据的时候(session.save(user))是没有问题的,但是在读取Blob字段(Oracle中存储byte[]使用的是"BLOB"类型)时就会出现问题,读出来的东西就成了乱码. 

使用hibernate读取Blob字段时,实体对象(对应的byte[]类型字段)应该这样定义:

对应的hibernate文件配置:

读取Blob数据方法:

关于输入输出流

读入流自然要有读入的源头,输出也要输出到某个地方,输出一般是先要输读入,这里连接输入和输出的是一个在内存中的字节数组buffer.这样从数据库中读到这个数组里,输出流在从这个数组中输出到特定的文件格式里。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn