4 Replies Latest reply on Jul 3, 2004 11:30 AM by gorano

    Generate GUID

    g00se

      I need to generate an 8 byte alphanumeric value which retains uniqueness over a minimum of a 90 day period. Uniqueness must be retained after application crashes or restarts. The application server is JBOSS 3.2.2.

      Is there a way to do this using a service already in JB?

        • 1. Re: Generate GUID
          cbuckley

          What is the id being used for (Primary key in DB)? Than how are you accessing the db straight jdbc or something else like CMP or Hibernate? JBoss has built in facilities to generate UUID's.

          • 2. Re: Generate GUID
            cbuckley

            Oh yeah probably not the best place for this post. Sorry.

            • 3. Re: Generate GUID
              g00se

              >>What is the id being used for

              Not sure sorry - i'm really asking the q on someone else's behalf!

              >>Oh yeah probably not the best place for this post. Sorry.

              What would a better one be?

              • 4. Re: Generate GUID
                gorano

                If you want a home made solution, you can always create a UUID table in your database.

                Create one field with the name and one field with
                value.

                You can implement a cmp, bmp or session bean to read the table, increase value and update.

                By creating a generic interface and a factory class you can make several implementations. You can for example take advantage of Oracle sequences in one of your implementations.

                Generic methods could be:

                getValue(String name);
                getNextValue(String name);
                setValue(String name, int val);

                e.t.c.

                This can be a nice solution, but it will of course
                give a certain overhead you should be aware of.

                By looking up Ids in the beginning of a transaction you can create nice asynchronous B2B solutions that can handle a very high temporary load (preliminary check of request data and id sent back as transaction id for later reference).

                /Goran