UUID and Java :)

by Szymon LipiƄski
tags: database java

Well, UUID stands for something UNIQUE. How that happened that it simply doesn’t work? Or even worse: it doesn’t work sometimes.

I had to use a program which generates some random data in the database. The primary key is UUID, so the program generates a lot of UUIDs. It uses the standard Java’s way of generating UUIDs, the function: UUID.randomUUID().

That program failed twice, it was a database error. The error was that the UUID exists in the database. I’ve created only a litttle bit over 50k of database rows. There were two collisions.

I told that the author of the software, he said that he had the same situation last week.

It looks like I was really lucky to get the same UUID randomly generated twice :)