aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate BLOB retrieving Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate BLOB retrieving" Watch "Hibernate BLOB retrieving" New topic
Author

Hibernate BLOB retrieving

Shaik Mohammed Arif
Greenhorn

Joined: Aug 06, 2008
Posts: 7
Hi all,
i am working with BLOB and and i am getting a null pointer exception when i tried to retrieve a Blob from database..

Here is my code..

try {
textfile = document.getBinaryBlob();
InputStream is = document.getBinaryBlob().getBinaryStream();
while (is.read(buffer) > 0) {
outStream.write(buffer);
}

outStream.close();

Please help me in this regards..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43321
    
  32
NullPointerExceptions are hardly advanced topics!

You are calling document.getBinaryBlob() twice; your 2nd call should read textfile.getBinaryStream();

Either "document" or "outStream" is null in that block. You should be able to work out which from the stack trace which gives line numbers.

And in future, please provide more details; it would have been much easier to answer with copy of the stack trace. And please use the code button when you quote code like that; it makes it much easier to read.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate BLOB retrieving
 
jQuery in Action, 3rd edition