-->
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.  [ 3 posts ] 
Author Message
 Post subject: ClassCastException using Blob while saving
PostPosted: Fri May 05, 2006 7:27 am 
Newbie

Joined: Thu May 04, 2006 12:57 am
Posts: 8
below is code snippet for the saving blob to database
I get a classcastException

**oracle.sql.BLOB blob = (oracle.sql.BLOB)(b.getWrappedBlob());**
If I print the type of class it is: it correctly shows oracle.sql.BLOB blob

Any idea how to get rid of this problem

If I used the CP30 connection pooling, I did not face this issue
On changing to the use the JDBC connection pooling set up as a datasource I get this problem

Please help

Code below:
----------------------------------------------------------------------

Session session = getCurrentSession();
Transaction tx = session.beginTransaction();

OutputStream os = null;
HibernateLOBSupport f = null;
BlobValueBean objBlobBean = new BlobValueBean();
try
{

f = objBlobHolder;
if(null!=f)
{
objBlobBean.setBlobData(Hibernate.createBlob(new byte[1]));
f.setBlobBean(objBlobBean);

session.saveOrUpdate(f);
session.flush();
session.refresh(f,LockMode.UPGRADE); //grabs an Oracle BLOB
try
{
if(null != f.getArrByte())
{

SerializableBlob b = (SerializableBlob)f.getBlobBean().getBlobData();
System.out.println("CLASSNAME:b.getWrappedBlob():"+b.getWrappedBlob().getClass().getName());
oracle.sql.BLOB blob = (oracle.sql.BLOB)(b.getWrappedBlob());
os = blob.getBinaryOutputStream();
os.write(f.getArrByte());

}
}
catch(HibernateException e)
{
throw new InfrastructureException(WablinkConstants.getInstance().getConstants("EXCEPTION.INFRASTRUCTURE.MAX_FILESIZE_EXCEEDED"),e);
}
os.flush();
os.close();
tx.commit();
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 1:30 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Have you checked information about Blobs from this link in documentation http://www.hibernate.org/56.html


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 06, 2006 9:15 pm 
Newbie

Joined: Sat May 06, 2006 8:08 pm
Posts: 4
The 10.2 version of the Oracle JDBC drivers will let you bind large String values to Clob colums. And Oracle always recommends that you use the latest version of the drivers. 10.2 is backwards compatible with Oracle Database 8.1.7 and later.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.