-->
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: problems writing a blob to mysql
PostPosted: Fri Mar 26, 2004 6:20 am 
Newbie

Joined: Fri Mar 26, 2004 5:41 am
Posts: 2
Hi -

I use Hibernate 2.1.2, Tomcat 4.1.29, mysql 4 and mapped a
blob to byte[] as descibed in http://www.hibernate.org/73.html using a UserType.
In my application I have 2 blob columns in the database. I read the first column (a thumbnail), convert it and try to write it back to the second column.
However, I get an exception in method nullSafeSet of the UserType when
the session is flushed:
net.sf.hibernate.lob.BlobImpl.excep(BlobImpl.java:95)
at net.sf.hibernate.lob.BlobImpl.getBytes(BlobImpl.java:48)
at com.mysql.jdbc.PreparedStatement.setBlob(PreparedStatement.java:358)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:260)
at MyBinaryBlob.nullSafeSet(BinaryBlob.java:57)


For nullSafeSet I tried

public void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException
{
if (value!=null) {
Blob b=new BlobImpl((byte[])value);
st.setBlob(index, b);
}
}


and alternatively
st.setBlob(index, Hibernate.createBlob((byte[]) value));

isMutable() returns true.

Thank you for any solution hint -
Christian


Top
 Profile  
 
 Post subject: add: problems writing a blob to mysql
PostPosted: Fri Mar 26, 2004 6:22 am 
Newbie

Joined: Fri Mar 26, 2004 5:41 am
Posts: 2
sorry, I forgot the message of the exception:

java.lang.UnsupportedOperationException: Blob may not be manipulated from creating session


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 11:52 am 
Newbie

Joined: Fri Feb 18, 2005 7:14 pm
Posts: 5
Location: State College, PA
Hello! I am running into this exact problem. Do you recall how you solved it? Many thanks!!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 4:28 pm 
Newbie

Joined: Fri Feb 18, 2005 7:14 pm
Posts: 5
Location: State College, PA
FYI to any who might happen to stumble upon this thread in the future: I fixed the problem by changing setBlob to setBytes, and everything now works!


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.