4 Replies Latest reply on May 24, 2002 1:41 AM by Jukka Koskimaki

    Arrays in finders

    Robson Newbie


      I'm having a problem with a finder, in a CMP2 bean. One of the fields in the query is a byte[] (in my case, a binary field with 16 bytes). Declaring it in method-param returns an error saying that it could not load byte class.

      Looking at the code, it seems that arrays of fundamental types are not supported. Anyway, I changed JDBCQueryMetaDataFactory.convertToJavaClass() to check for array and it didn't work. There's some more thing I need to know??
      Overriding this finder in EJB class gives me a warning when I deploy the ear...


        • 1. Re: Arrays in finders
          Dain Sundstrom Master

          Post a bug report. By the way, why is it useful? What are you going to use a byte[] parameter for?

          • 2. Re: Arrays in finders
            Robson Newbie

            I store a MD5 hash of a user password in this field. Anyway, there's nothing that prevents me to storing this information converted to hexa (in a string field)...

            • 3. Re: Arrays in finders
              Dain Sundstrom Master

              Interesting idea. I like to hear about example uses, because it helps me remember what to check for when coding.

              • 4. Re: Arrays in finders
                Jukka Koskimaki Newbie

                Hello !

                Here are two examples of usage of byte[] as an
                Entity bean attribute( field).

                1) In the field of enterprise applications there is often
                need for enterprise-wide object identifiers. Couple of
                standards describe them, but common nature for them is
                that are purely binary strings ( or binary arrays).
                They have nothing to do with character strings and
                consequently mapping them to character strings is unwanted
                complication and overhead.
                At the Java level byte[] handles properly those object identifiers, at the JDBC level varbinary do the same
                and at the DB level Oracle's RAW or PostgreSQL's bytea is proper datatype.

                2) In the security field many applications have to handle
                entities like certificates, keys, fingerprints, etc.
                Again, their nature is purely binary string, they have nothing to do character strings in most cases.

                *) Mapping something whose nature is to be binary string
                to charcter string
                is problematic from performance point of view, because
                all subsystems underneath believe that it really is
                character string and behave accordingly:

                -- Java String checks whether character sets are
                handled properly when content leaves/arrives it.

                -- JDBC drivers checks the same thing

                -- Database checks how the incoming character string
                maps to its own configured character-set.

                In some cases it is possible that some system part actually changes the content of data due to character set