-->
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.  [ 1 post ] 
Author Message
 Post subject: Need help with MySQL varbinary -> byte[] with @Lob
PostPosted: Wed Jan 20, 2010 5:34 pm 
Newbie

Joined: Wed Jan 20, 2010 5:23 pm
Posts: 2
Dear community,

First off, my appologies if this has been asked before, but I'm having severe difficulties accessing my varbinary field in a MySQL database:

Field is defined as varbinary(16).
Mapping to POJO byte[] decorated with @Lob annotation.

Code is as follows:

Code:
@Entity
@Table( name = "aim" )
@Cache( usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE )
public class AIM implements Serializable
{
   private static final long   serialVersionUID   = 1810350495885144529L;

   @Id
   @Column( name = "id" )
   @GeneratedValue( generator = "increment" )
   @GenericGenerator( name = "increment", strategy = "increment" )
   private Long ID;
   
   @Column( name = "is_tracked" )
   private boolean isTracked;
   
   @Lob
   @Column( name = "alt" )
   private byte[] alt;

   public AIM() {
      
   }
   
   public Long getID()
   {
      return ID;
   }

   public boolean isTracked()
   {
      return isTracked;
   }

   public byte[] getAlt()
   {
      return alt;
   }

   public void setID( Long ID )
   {
                          this.ID = ID;
   }

   public void setTracked( boolean isTracked )
   {
      this.isTracked = isTracked;
   }

   public void setAlt( byte[] alt )
   {
      this.alt = alt;
   }



This mapping file seems to work partially, as I can use it to get records from the database from this table, and I can then access the simple fields fine, but whenever I try to use the getter for the 'Alt' field, I get a NullPointer Error.

Can anyone shed some light on this for me? I can post more code if necessary.
Thanks in advance, help would be greatly appreciated!

Cheers.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.