Hi all,
in Syncope we are currently discussing [1] the option to replace our
table generators-based id strategy to something else, based on UUID,
which seem to offer several advantages.
I have found [2], but I would rather prefer to generated UUID values
manually (via [3] which seems to offer better performance and more
features than the standard JDK's).
In order to do so, I would replace the current
@Id
private Long id;
public Long getKey() {
return id;
}
in [4], backed by [5], with something like as
@Id
private UUID id;
public UUID getKey() {
synchronized(this) {
if (key == null) {
key = ... // generate via JUG [3]
}
}
return key;
}
As Syncope supports several DBMSes, I would also like to empower the
underlying capabilities for storing such values:
* UUID Type for PostgreSQL [6]
* UNIQUEIDENTIFIER for SQL Server [7]
* RAW(16) for Oracle [8]
* BINARY(16) with some optimizations for MySQL / MariaDB [9] or
vanilla with H2
Do you have any suggestion about:
(a) the way how I am planning to support UUID generation
(b) the cleanest way to support DBMS differences (extending the
respective DB dictionaries?)
TIA
Regards.
[1] http://markmail.org/message/fhdrwerdwdm3opdx
[2]
http://openjpa.apache.org/builds/2.4.1/apache-openjpa/docs/jpa_overview_meta_field.html#jpa_overview_meta_gen
[3] https://github.com/cowtowncoder/java-uuid-generator
[4]
https://github.com/apache/syncope/blob/master/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
[5]
https://github.com/apache/syncope/blob/master/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml#L87-L94
[6] http://www.postgresql.org/docs/9.3/static/datatype-uuid.html
[7] http://wiki.ispirer.com/sqlways/sql-server/data-types/uniqueidentifier
[8]
http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions175.htm#SQLRF51816
[9] https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/
--
Francesco Chicchiriccò
Tirasa - Open Source Excellence
http://www.tirasa.net/
Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC, CXF committer
http://home.apache.org/~ilgrosso/