1 Reply Latest reply on Nov 23, 2006 3:18 AM by tcomtcom

    Problem with @Lob annotation and MySql

    tcomtcom

      Hi,
      I want to persit a photo of a person in my database. In order to do that, I'am using the code below:

      @Entity
      @Table(name="PERSONNE")
      @Inheritance(strategy=InheritanceType.JOINED)
      public class Personne implements Serializable{
      
       private ImageIcon photo;
       ...
      
       @Lob
       @Basic(fetch=FetchType.LAZY,optional=true)
       @Column(name="PHOTO")
       public ImageIcon getPhoto() {return photo;}
       public void setPhoto(ImageIcon photo) {this.photo = photo;}
       ...
      }
      


      When I persist the entity, it's Ok but when I'am trying to extract it form the DB I got an EOFException.
      @Lob make the attibute photo mapped as a blob but Blob type in MySQL seems to not support more than 64kB of data. In most of case my photos have a bigger size than 64KB and they are simply truncated.
      To resolve the problem, I changed the type directly in the DB into LongBlob and now it is working fine.
      So, my question is : Is there a way to have my attribute directly mapped as a LongBlob?

      Thanks in advance

      System informations:
      jboss 4.0.4.GA
      EJB RC8
      MySQL 4.1.9 and connector 3.1.14





        • 1. Re: Problem with @Lob annotation and MySql
          tcomtcom

          I solved the problem by simply using @Column wtih columnDefinition="LONGBLOB".

          For your information, I found out that it is not the Blob type which limits the data size. If the type of the table is MyISAM, each line cannot exceed 64KB.

          Bye