-->
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: Problem with BLOBs in DB2
PostPosted: Mon Feb 27, 2006 3:19 am 
Newbie

Joined: Thu Jan 26, 2006 1:54 am
Posts: 4
Has anyone got hibernate successfully working with blob columns in DB2? I have tried without much success. I am having problems inserting the blobs (essentially, mapped to java.lang.String since these blobs are for large string messages). They seem to be working for the most part when I alter the columns to be varchar(N). I am doing everything else fine in the code (since I got this working with mysql) and was hoping that the migration to DB2 would be smooth. Please send me anything I should be checking or be aware of (tips, known issues, etc.) to get blob columns to work w/ hibernate.

Thanks in advance!
-Ron


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 9:23 am 
Beginner
Beginner

Joined: Fri Feb 17, 2006 1:28 pm
Posts: 24
Hey Ron,

I had a similar problem the what I did was to change the java bean type to be a byte array. And also kept a method in the bean (which the app itself would use) to get the BLOB field.

So in this example, we have a field of type BLOB and just trying to retrun it as a string.



Code:
   public String getPassword()
   {
      return password;
   }
   
   
   public void setPassword(String password)
   {
      this.password = password;
   }


This will end up causing you problems when returning the String. If you change your code to the following and allow hibernate to use the getPassword() and setPassword() method, then ur app can use the getPasswordAsString() and just have another setPassword method which takes different params.

Code:
public byte[] getPassword()
   {
      return password;
   }

public void setPassword(byte[] password)
   {
      this.password = password;
   }
   
public void setPassword(String password)
   {
      setPassword(password.getBytes());
   }

public String getPasswordAsString()
   {
      return new String(password);
   }


Give that a try and let me know if this is any use to you.


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.