On Wed, 26 Jul 2000, john cooney wrote:
> I would like to know how I can develop a generator, which generates
> in sequence, unique primary keys for separate Container Managed
> Entity Beans.
>
> Has someone already developed this kind of code?
I'm sure that primary key generators have been developed over and
over again by the members of this list. My particular implementation is the
open source (LGPL) UniqueId entity bean available at
http://www.simscomputing.com/products/etk/
It's simple, really. It hands out unique Java long values. I'd suggest simply
looking at the code to get a feel for how it works. I've planned for a long
time on expanding the different unique ID types that it can support, but
currently it only really works for SQL BIGINT/long values.
This brings up an interesting point. I know that with a BIGINT I can generate
2^63 unique IDs before running out, and that in most applications, this won't
be a problem. However, the short-sightedness of some of the Y2K code reminds me
that I really want a PK generator that can create an infinite range of primary
keys.
My big question, then, is: what standard SQL type is best for that? CHAR and
VARCHAR require you to specify sizes, which means that you eventually exhaust
the sequence. So does VARBINARY. In fact, it seems that no standard SQL type is
capable of generating an infinite sequence of primary keys.
Granted, 63 or 127 bits go a *very* *long* way, but still, it seems
shortsighted since in the coming centuries, it seems possible that we may have
software running for hundreds of years at a time.
-david
--
David Sims [EMAIL PROTECTED]
Sims Computing, Inc. www.simscomputing.com
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".