0 Replies Latest reply on Sep 19, 2007 12:27 PM by smithbstl

    Multiple Generators in one entity


      Is there any way to reference multiple @TableGenerator or @SequenceGenerator annotations in an entity?

      I have a use case where I am using one table to generator primary key values for all my entities. For two entities, I wish to to generate a business key (serial number). The number is not really important but I don't want it to grow as fast as it would if I used the primary key generator.

      I am using @TableGenerator in testing with HSQLDB but will switch to @SequenceGenerator when I move to production (Oracle).

      If this is not possible, is there some other way I can generate business keys that increment? (Gaps in the numbers are not really important)

      Or if possible generate unique random numbers?

      Ultimately the business key will be something like mm-dd-yyyy-xxxx or aaa-xxxx where xxxx is the number generated and prefixed either with a date string or with some alpha numeric value like a department number.