-1

I have a system analyst that insist of using oracle sequence instead of UUID because he is not familiar with it.

I have the few question and hope the community can assist me.

1) How is hibernate UUID generated to ensure uniqueness?

I know oracle SYS_GUID() uses

SYS_GUID generates and returns a globally unique identifier (RAW value) made up of 16 bytes. On most platforms, the generated identifier consists of a host identifier, a process or thread identifier of the process or thread invoking the function, and a nonrepeating value (sequence of bytes) for that process or thread

2) In an event the UUID is used, will hibernate auto regenerate a UUID to commit the row?

I know this scenario is rare but if hibernate can do that, but he insist there is a chance that will happen and the transaction will fail.

3) What are benefits of using UUID over oracle sequence generator?

seesee
  • 1,145
  • 5
  • 20
  • 46
  • any reason why I'm getting - points? – seesee Jul 31 '13 at 02:06
  • A Hibernate UUID appears to be 128 bytes, which is gazillions of times less likely to regenerate the same value, but why even discuss it? If you do it his way you can't be wrong. – user207421 Jul 31 '13 at 02:08
  • The authority is a pain, he insist 1 in gaillions of times is still a chance. – seesee Jul 31 '13 at 02:09
  • Surely he can understand that repetition over 128 bytes is gazillions of times less likely than over 64 bytes? And I do mean gazillions: 2**512 to be precise. This is rather a large number. But if he doesn't understand that, why not do it his way? – user207421 Jul 31 '13 at 02:11
  • @EJP 128 bits not bytes, surely? – Dev Jul 31 '13 at 02:23
  • @Dev Hmm, musta misread it. If it's bits then it comes down to the algorithm, but as you say in your answer it's improbably unlikely either way. – user207421 Jul 31 '13 at 02:30

1 Answers1

2

Rare doesn't even begin to describe the remote possibility of randomly generating the same UUID twice.

As shown in the Wikipedia arcticle about UUIDs

Possibility of a clash after n attempts.

n                               probability
68,719,476,736 = 2**36          0.0000000000000004 (4 × 10−16)
2,199,023,255,552 = 2**41       0.0000000000004 (4 × 10−13)
70,368,744,177,664 = 2**46      0.0000000004 (4 × 10−10)

You could generate UUIDs at a rate of 1 million per second for 814 days and only have a 4 * 10**-10 chance of generating a duplicate.

Not to mention Advantages and disadvantages of GUID / UUID database keys

Community
  • 1
  • 1
Dev
  • 11,919
  • 3
  • 40
  • 53