vaadin / starters

Issue repository for all the starter projects in https://vaadin.com/start
3 stars 0 forks source link

Change ID generation strategy on entities #83

Closed simasch closed 1 year ago

simasch commented 1 year ago

The uuid-char ID generator is a Hibernate proprietary feature. Plus a UUID may not be the best strategy performance-wise.

@Type(type = "uuid-char")
private UUID id;

You should consider using only JPA standard features.

Artur- commented 1 year ago

Is there really any case when this is a performance problem? It could be an integer instead, with somewhat less security as you can guess the previous and next id

Artur- commented 1 year ago

JPA 3.1 seems to have @GeneratedValue(strategy = GenerationType.UUID)

simasch commented 1 year ago

Sequence is the most common way. UUID generation is slow on mass inserts. Also depending on the database used UUIDs are stored differtly. IMO we should use what the most common strategy is.

simasch commented 1 year ago

https://www.cybertec-postgresql.com/en/uuid-serial-or-identity-columns-for-postgresql-auto-generated-primary-keys/

tarekoraby commented 1 year ago

Isn't it the case that UUID is more favorable security-wise?

simasch commented 1 year ago

Not really because for performance improvement databases generate serial UUIDs

Artur- commented 1 year ago

Ids are now Long and use sequence based generation, which seems what most people recommend