I would agrre with the objection to the uniqueness if the random generation.

I prefer the own generator, which is database based and allows to build the
PK from different parts - e.g. installation number is included in PK. The
disadvantage is that the generator must be transaction safe - but it is
worth to deal with just in batch operations - for these cases it can return
the range of PKs.


Mark

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Richard
> Kasperowski
> Sent: 26. eervna 2001 17:07
> To: [EMAIL PROTECTED]
> Subject: Re: [JBoss-user] Key generation by random numbers
>
>
> [EMAIL PROTECTED] wrote:
>
> > As a follow-up to the debate on how to get auto-increment primary
> > keys:
> >
> > Is it feasible to use a random number generator to generate primary
> > keys? I don't really need my records to have steadily increasing keys
> > and my number of records will presumably be much smaller than the size
> > of my value space (4 billion? depending on data type for prim-key). So
> > if I do something along the following when making a new record;
> >
> > boolean created = false;
> > do
> > {
> >    Long key = generateRandomLong();
> >    created = ejb.create(key, contents);
> > }
> > while (!created);
>
>
> One problem with using random numbers is that they're not guaranteed to
> be unique--two calls to generateRandomLong() can return the same value.
>   Another problem is that computing the next random number might be
> relatively computationally expensive.  I'd say serial numbers are better.
>
> --
> Richard Kasperowski (mailto:[EMAIL PROTECTED])
> Tel: 617-576-1552, Fax: 617-576-2441
> http://www.altisimo.com/
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.256 / Virus Database: 129 - Release Date: 31.5. 2001
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.256 / Virus Database: 129 - Release Date: 31.5. 2001


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to