-->
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: Generic Blob retrieval?
PostPosted: Mon Aug 01, 2005 7:28 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.8

Code between sessionFactory.openSession() and session.close():
Session saveSession = getDedicatedSession();
ai.setAttach(Hibernate.createBlob(new String(" ").getBytes()));
saveSession.save(ai);
saveSession.flush();
saveSession.close();

saveSession = getDedicatedSession();
AttachmentInfo attachmentInfo = (AttachmentInfo)saveSession.load(AttachmentInfo.class,new Integer(ai.getAttachID()),LockMode.UPGRADE);

oracle.sql.BLOB blob = (oracle.sql.BLOB) attachmentInfo.getAttach();
OutputStream os = blob.getBinaryOutputStream();
os.write(attachObject);
os.close();
saveSession.close();

Name and version of the database you are using:
Oracle 9i


Hi

I have searched the forum, but couldnt get what i desired.

I need to support DB2 and SQL server too, Currently i am using Blob for Oracle i.e)
oracle.sql.BLOB blob = (oracle.sql.BLOB) attachmentInfo.getAttach();

Can i make this retrivel generic with out hardcoding the import i.e)oracle.sql.BLOB

Waiting for replies

Thanks team

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 3:37 pm 
Beginner
Beginner

Joined: Tue Jul 19, 2005 5:08 am
Posts: 26
Location: Germany
hi ramnath,

i´m using blobs with oracle 9i too and with db2 in the same application. But instead of the oracle blob type i´m using java.sql.blob, works fine.

greetings

arno


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.