Support for java.util.UUID as @Id Column in SQL Databases
See original GitHub issueOverview of the issue
Feature Request: Allow the use of java.util.UUID as ID with SQL Databases
Motivation for or Use Case
It may not be as fast as Long, but can be generated safely outside the database, being an interesting option for microservices using separate databases
With Spring Data included in Spring Boot 1.5.1, both Spring Data JPA and Spring Data Elasticsearch support Repositories with java.util.UUID as ID. Also Hibernate v5.2.4 (used in JHipster 4) supports @GeneratedValue without the need to define any custom generator
I tested a monolith application using JHipster v4.0.0 with PostgreSQL, using H2 as test database, and after upgrading to Spring Boot 1.5.1, no @UserType or any configuration of the sort was needed, setting the column type as “uuid” in liquibase was enough
I don’t know if the other databases supported by JHipster also support uuid as a column type, but if the user wants to use UUID even if the selected database doesn’t support it, the key could be a varchar(36) or varchar(32) (UUID without dashes)
Related issues
If such feature is added, it’s better to wait until #5045 is merged
JHipster Version(s)
v4
JHipster configuration
Entity configuration(s) entityName.json
files generated in the .jhipster
directory
Browsers and Operating System
- Checking this box is mandatory (this is just to show you read everything)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
@DanielSBFranco : I added my code. Its not extensively tested but we have been using this internally for almost 10 months with minimal problems. See here: https://github.com/amitjindal/generator-jhipster-postgresuuid-converter
In next few days I will polish this and submit this to NPM repository.
@DanielSBFranco Just released latest version with change as you requested. Please take a look.