-->
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: Mapping byte[] under MySQL
PostPosted: Sun Jul 25, 2004 3:50 am 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
Hi,

I am trying to map a "byte[]" property under Hibernate with MySQL running under the hood. I tried mapping the byte[] to type "blob" but I would get the following exception:

java.lang.ClassCastException: [B
net.sf.hibernate.type.BlobType.set(BlobType.java:27)
net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.java:393)
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:527)
net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:432)
net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:932)
net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:857)
net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:775)
net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
com.tog.desktopbeautifier.AddImage.processRequest(AddImage.java:79)
com.tog.desktopbeautifier.AddImage.doGet(AddImage.java:110)
javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

So then I mapped the property to "binary" and that worked except that I noticed it is being saved as a "varchar(255) binary" type in the database. Is that correct? Is there 255-character limit artificial? I need to store large amounts of data in this property, definately over 255 characters.

Please clarify what is the appropriate mapping to be used for byte[] under MySQL or any other database (if there is a general solution).

Thank you,
Gili


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 25, 2004 11:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
<property name="foo" type="binary" >
   <column name="foo" sql-type="blob"/>
</property>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 25, 2004 1:25 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
gavin wrote:
Code:
<property name="foo" type="binary" >
   <column name="foo" sql-type="blob"/>
</property>


Thank you!


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.