-->
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.  [ 4 posts ] 
Author Message
 Post subject: Saving Hibernate blobs - ClassCastException
PostPosted: Wed Nov 19, 2003 10:19 am 
Beginner
Beginner

Joined: Tue Sep 30, 2003 10:09 am
Posts: 34
Location: London, UK
I'm trying to save a blob I created from Hibernate.createBlob(InputStream). The db is currently mysql.

I get:

java.lang.ClassCastException
at net.sf.hibernate.type.BinaryType.deepCopyNotNull(BinaryType.java:89)
at net.sf.hibernate.type.NullableType.deepCopy(NullableType.java:89)
at net.sf.hibernate.type.TypeFactory.deepCopy(TypeFactory.java:198)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:712)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605)


I'm guessing this is because BinaryType.deepCopyNotNull() expects to be able to copy the byte[] from blob, whilst I'm assuming that the blob only has the InputStream.

There's a similar problem described at http://forum.hibernate.org/viewtopic.php?t=924398, but none of the replies seem to fit the bill.

Help!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 10:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
use type="blob", not type="binary".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 10:56 am 
Beginner
Beginner

Joined: Tue Sep 30, 2003 10:09 am
Posts: 34
Location: London, UK
Seems to do the trick - thanks.

Do I also need to set the "hibernate.jdbc.use_streams_for_binary" property to true?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 10:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ummm probably not, but i don't think it hurts


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