-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to use byte[] with annotations?
PostPosted: Mon Mar 14, 2005 6:16 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Hibernate version: hibernate-3.0rc1, hibernate-annotations-3.0alpha3

I have a POJO which has a property like the following. I found that when I run SchemaExport to create the database schema that it sets the SQL data type to tinyint.

Code:
public byte[] getCV() {
   return cv;
}


I'm able to specify that the data type should be longblob using the following annotation.

Code:
@Column(columnDefinition="longblob")


However, when, I attempt to persist the object, I receive the following exception. I think it's basically treating the byte[] as a byte instead.

Code:
Caused by: java.lang.ClassCastException: [B
        at org.hibernate.type.ByteType.set(ByteType.java:38)


I found the following link which describes how to deal with BLOBs using a custom UserType and a mapping file. What I'm wondering is if I'll need to use a mapping file to do what I want to do?

[url]http://www.hibernate.org/73.html
[/url]

The other thing that I'm wondering is if there is a DBMS independent way to deal with BLOBs? Or, is it the case that you pretty much have to write DBMS specific code when using BLOBs? If it's the later, I'll probably just store the data in the file system instead.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 6:49 am 
Newbie

Joined: Wed Jan 26, 2005 10:51 pm
Posts: 3
Location: Taiwan
I use @Type(type="binary") and it works.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 15, 2005 12:18 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Thanks for the pointer. I'll give that a try. I was just looking at the EJB annotations. I hadn't realized there were Hibernate specific ones there. I heard about them, I just didn't realize they already exist. One thing that would be great is if the next version of the annotations package included java docs documentation. So, far I just been running javadoc myself except I receive a lot of errors because I don't think I have my build environment setup correctly.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 18, 2005 5:32 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Serialized will be available in the next version and its plain EJB3 :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject: @Serialized removed
PostPosted: Fri Jul 08, 2005 7:02 pm 
Newbie

Joined: Fri Jul 08, 2005 5:18 pm
Posts: 10
It looks like @Serialized was remove.


Is there any EJB 3 compliant to map a binary to a byte[]?

I can use the @Type, but I would prefer not to use Hibernate specified stuff if possible.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 12:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I fixed the bug in Annotations HEAD
it should be the default for byte[] annotated with @Basic or not annotated at all.

In the current version, @Type is required. Sorry about that.

_________________
Emmanuel


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