4 Replies Latest reply on Jun 29, 2005 8:32 AM by gaferrero

    CMP, MYSQL & Blob

    gaferrero

      Hi all,

      I'm deploying a simple application that uses JBOSS and CMP with MySQL data base,
      i have a little problem with a persistence field (blob field type in MySQL), could anyone help me with a simple example or
      with anything that you know about it, i want to storage an image saved in arrays of bytes (byte[] image).

      Best regards...

      Gustavo.

        • 1. Re: CMP, MYSQL & Blob

          for a start just use byte[] as your method type it would be converted automatically to corresponding default data type in the database

          • 2. Re: CMP, MYSQL & Blob
            gaferrero

            Thanks for replie, i still have the problem, when i retrieve the image in the client application and exception happens

            Caused by: java.io.NotSerializableException: sun.awt.windows.WImage
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)
            at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1332)
            at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1304)
            at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1247)
            at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1052).....

            When i disable the retrieve image field the application works fine.

            What happen?

            Thanks...

            • 3. Re: CMP, MYSQL & Blob

              what the method signature of the image in your entity bean

              • 4. Re: CMP, MYSQL & Blob
                gaferrero

                Thanks again for your reply tomerbd2, the method in the entity bean is

                public abstract byte[] getImagen();
                public abstract void setImagen(byte[] imagen);

                In the SessionBean i call getImagen() and pass its return value to the ImagenMamo constructor, this class is serializable.