-->
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.  [ 1 post ] 
Author Message
 Post subject: Blob Syntax
PostPosted: Tue Jun 08, 2004 2:37 pm 
Newbie

Joined: Thu Jan 29, 2004 2:51 pm
Posts: 9
Hi guys...my blobs are (more or less) working fine but I have a question about the syntax.

Generally speaking I'm doing (this is code paraphrase):

Code:
InputStream stream = ...
Blob blob = Hibernate.createBlob(new byte[1]);
BlobTestBean bean = new BlobTestBean();
bean.setBlob(blob);
session.save(blob);


I'm not sure what the second statement does. I've seen different examples on this site, like

Code:
Blob blob = Hibernate.createBlob(stream);


but I get an Exception: Caused by: java.sql.SQLException: Io exception: Software caused connection abort: socket write error

I've also tried

Code:
Blob blob = Hibernate.createBlob(new byte[0]);


but I get a NullPointerException

So I've settled on

Code:
Blob blob = Hibernate.createBlob(new byte[1]);


Because one has to save and then refresh the object to write binary data to a Blob, is there any reason other than calling

Code:
Blob blob = Hibernate.createBlob(new byte[1]);


to create Blob before saving? In the end, all you need to do is save the object, refresh it, get the Blob back (which is now a database specific blob) and write the bytes to it.

Thanks, Steve


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

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.