-->
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: Saving Blob's underlying stream length
PostPosted: Wed Oct 04, 2006 9:21 pm 
Newbie

Joined: Tue Aug 09, 2005 7:30 pm
Posts: 3
Hi,

I'm saving a Blob in the database, it's all working fantastically. I get a stream from a web service, embed it in a Blob object, then call "save(hibernateObjectWithBlob)". What I would like to be able to do it get the length of the stream/Blob and save it to the database.

I figured that I could do this by (all in one transaction):
1.) Create a new hibernate object in the database
2.) Set the blob as an attribute on the object
3.) Save the object
4.) Intercept the stream's read calls to work out how long the stream is
5.) Set the length of the stream as an attribute on the hibernate object from step 1
6.) Call an update on the object from step 1

This didn't work to plan - I'm getting the correct length of the object I'm interested in, but can't seem to put the value into the database. I believe this is due to the fact that the stream is not being read until one of the later phases of the transaction, after all normal object commits have completed.

I also tried changing the algorithm so the update for the length happens when the stream is closed... but again same problem, the call on the hibernate object is happening at one of the later parts of the transaction and doesn't filter down to the database.

That being considered - is there an easier way to do what I want... seems awfully hard for what should be a trivial task.

Cheers,

Dave


Top
 Profile  
 
 Post subject: Found alternate answer
PostPosted: Wed Oct 04, 2006 9:55 pm 
Newbie

Joined: Tue Aug 09, 2005 7:30 pm
Posts: 3
Heh, just found an alternate method to get the length. I'm using XFire as my web service tier so I can just grab the file size from the AttachmentDataSource which is the origin of the stream for the Blob: )


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.