1 Reply Latest reply on Feb 16, 2006 3:17 PM by Jens Elkner

    Blob No Such Method Error

    Matt Johnston Newbie

      I am trying to post images to my database (Postgres 8.1), but I am running into some errors. My entity looks like

      private Blob image;
      @Column(name = "image", nullable=false)
       @Lob(fetch = FetchType.LAZY, type = LobType.BLOB)
       public Blob getImage() {
       return image;
       }
       public void setImage(Blob image) {
       this.image = image;
       }
      


      Then in my code to store the image, I use
      byte[] bytes = ...
      SerialBlob blob = new SerialBlob(bytes);
      image.setImage(blob);
      


      Everytime I run that, I get an error that "java.lang.NoSuchMethodError: com.pga.recipe.entity.WebImage.setImage(Ljava/sql/Blob;)V"

      In my entity, I have tried setting the blob field as a Blob, Byte[] and byte[] and I still get the same error. I have verified that the byte array I am trying to store does contain data. Does anyone know what causes this problem?


        • 1. Re: Blob No Such Method Error
          Jens Elkner Apprentice

          My blobs work wo any problems (and did with the old notation in 4.0.3x) as well. IMHO there is no need to wrap that array into something else:

          @Lob @Basic(fetch=FetchType.EAGER, optional=true)
           @Column(name="image", length=262144)
           public byte[] getImage() {
           return image;
           }
           public void setImage(byte[] image) {
           this.image = image;
           }


          Easy to [re]create the image on a gui: new ImageIcon(byte[]).