jQuery in Action, 3rd edition
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate BLOB retrieving" Watch "Hibernate BLOB retrieving" New topic

Hibernate BLOB retrieving

Shaik Mohammed Arif

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) {


Please help me in this regards..
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46397
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
It's not a secret anymore!