[keycloak-dev] Use UUID for IDs

Marek Posolda mposolda at redhat.com
Tue Feb 11 18:38:56 EST 2014


I wonder if it's not better to just use Long instead of String? In 
GateIn portal we use old Picketlink IDM backed by Hibernate and we have 
autogenerated Ids of type Long, which are "externally" seen as Strings, 
so it's not a problem to keep getId() method in API returning String.

See the class here (and getter/setters for Strings): 
https://github.com/picketlink/picketlink-idm/blob/1.4/picketlink-idm-hibernate/src/main/java/org/picketlink/idm/impl/model/hibernate/HibernateIdentityObject.java#L55
and Hibernate mapping: 
https://github.com/picketlink/picketlink-idm/blob/1.4/picketlink-idm-hibernate/src/main/resources/mappings/HibernateIdentityObject.hbm.xml#L8

The most important thing is, that this is tested and works with all 
major databases (H2, MySQL, PostgreSQL, IBM DB2, Oracle, Sybase, MSSQL). 
Another thing is that long might have better performance than String.

I am not sure about the usecase with import/export stuff from/into 
completely different DB (like have data in H2, then export them and then 
import same data into MySQL). This may not work as different DBs may 
have different rules for allowing ID (some may have unique ID just for 
single table, some may enforce to have unique ID globally). However I am 
also not sure if String Id like "1-898928392" is allowed in all RDBMS...

Marek


On 11.2.2014 15:13, Bruno Oliveira wrote:
> +1 I guess TokenIdGenerator does the job well
>



More information about the keycloak-dev mailing list