-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: BLOB Streaming.
PostPosted: Wed Dec 10, 2008 5:42 am 
Newbie

Joined: Tue Mar 20, 2007 11:48 am
Posts: 11
Hi all,

I'm working on a project in which we are handling file upload/download.
I am thinking about an implementation that lets us upload and download files to and from the database using Hibernate, without ever holding the files in memory.
I'm wondering if there is a nice way to do this using Hibernate.


This is an example of what I would like to do:

Code:
Attachment attachment = ... (query attachment)
streamToClient(Attachment.getDataInput()) //Data is not in memory, but holds a stream to it.

and

save(File file) {
     Attachment attachment = new Attachment();
     streamToDB(Attachment.getDataOutput()) //Data is not in memory, but hold a stream to it.
}


Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2008 4:49 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
If you map your property as a BLOB (not byte[]) then you can actually use the BLOB stream API directly. You'll have to use this API within a transaction, but it should do what you want. On the way back out, the BLOB data won't be read until you actually get the bytes out of it, and again you have to do this within a Transaction.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.