I'm willing to use UUID as primary key for my java application entities using hibernate as my application ORM, and I'm generating the UUID on the server side. Here are the reasons why I'd like to use UUID as primary key:
- It removes the generation of ids from the database (It may be good for performance because it does not need to process the sequence logic on the database side)
- Equals and Hashcode easier and more performatic because I just need to use one field, Id.
- It solves the problem with detached entities with Equals and Hashcode because it's going to create when I create a new instance
- I can use equals and hashcode (only using id as mentioned above) on bidirectional relationship like in OneToMany without getting stack overflow exception.
- I won't care if the id is reaching its maximum value
But my concern is the performance on both retrieving and inserting, is there any impact? Do you know where I can find any benchmark for this?