-->
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.  [ 2 posts ] 
Author Message
 Post subject: Blob size too small at schema export.
PostPosted: Thu Aug 28, 2008 10:04 am 
Newbie

Joined: Thu Aug 28, 2008 9:46 am
Posts: 2
Hibernate version: 3.3.0.CR2

Annotations version: 3.4.0.CR2

Name and version of the database you are using: DB2 v8.1.16.429


Hi,

I am trying to store a file in the database. I am using Hibernate Annotations and read the file into a byte array which I annotated with @Lob :

Code:
@Lob
private byte[] myBlob;


This all works pretty well if I create the database table by myself. If I use the schema export feature, the Blob column in the database is only 255 byte long which is not enough for me.

So I wonder if there is a way to tell Hibernate through Annotations how large the maximum size of the byte array (and so the db column) should be, or maybe any other workaround other than changing the column afterwards by hand.
Would spare me some time/nerves during development.

Thanks in advance.



EDIT:
I just found the solution by myself.


Code:
@Lob
@Column(length=20971520)
private byte[] myBlob;


does the trick for me. It creates a blob column which can store up to 20 MB of data.

Sorry for this senseless topic. :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2008 7:49 am 
Newbie

Joined: Thu Aug 28, 2008 9:46 am
Posts: 2
Me again.

I just got another problem now:

I want to set the Blob size to the maximum possible in DB2, which is 2 GB.
Unfortunatly, the @Column(length) - field only takes int as argument, and 2 GB in bytes is too large to be stored in an integer.

What i would need is something like this:

Code:
import javax.persistence.Column;

public class Test {
   
   @Lob
   @Column(length=2147483648)
   byte[] array;
}


The above code doesnt work and btw leads to a pretty creepy bug in eclipse, which prevents you from opening the file again after saving.


Is there any other way to do that?

Thanks in advance.


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