-
Notifications
You must be signed in to change notification settings - Fork 13
10PrimeKeys
jDialects supply 10 prime key generators:
Put @UUID36 annotation on entity class's field or use Java method uuid36() to configure.
An ORM tool can use dialect.getNexID(col.getIdGenerator(), jdbc, col.getColumnType()) method to get a 36 letter length String, format example:"d3ad36c0-c6c2-495c-a414-b9cc4a0a7a93".
UUID36 based on Base16 encoding.
Put @UUID32 annotation on entity class's field or use Java method uuid32() to configure.
An ORM tool can use dialect.getNexID(col.getIdGenerator(), jdbc, col.getColumnType()) method to get a 32 letter length String, format example:"bca5414e9b1b4bdfa257125e05428b92".
UUID32 based on Base16 encoding.
Put @UUID25 annotation on entity class's field or use Java method uuid25() to configure.
An ORM tool can use dialect.getNexID(col.getIdGenerator(), jdbc, col.getColumnType()) method to get a 25 letter length String, format example:"pbicz3grgu0zk3ipe1yur03h7".
UUID32 based on Base36 encoding.
Use @UUIDAny annotation or uuidAny() Java method.
To define a any length UUID, An example:@UUIDAny(name="uuid50", length=50),or columnModel.uuidAny("uuid50", 50)。
If put annotation on class instead of on field,to use it use:@GeneratedValue(strategy = GenerationType.UUIDAny, generator = "uuid50") or tableModel.column("someField").idGenerator("uuid50");
UUIDAny based on Base36 encoding.
Use @IdentityId annotation or identityId() Java method. This type prime key only can be used when a database support Identity type.
Use @SequenceAnnotation annotation or sequence() Java method. This type prime key only can be used when a database support Sequence type. Example:
@SequenceGenerator(name = "seqID1", sequenceName = "seqName1", initialValue = 1, allocationSize = 10)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqID1")
public String someField;
or
tableModel.sequenceGenerator("seqID1", "seqseqName11", 1, 10);
tableModel.column("someField").LONG().idGenerator("seqID1");
Use @TableGenerator annotation or tableGenerator() method. Example:
@TableGenerator(name = "t1", table = "tb1", pkColumnName = "pkCol1", valueColumnName = "vcol1", pkColumnValue = "pkval", initialValue = 2, allocationSize = 20)
@GeneratedValue(strategy = GenerationType.Table, generator = "t1")
public String someField;
or
tableModel.tableGenerator("t1", "tb1", "pkCol1", "vcol1", "pkval", 2, 20);
tableModel.column("someField").LONG().idGenerator("t1");
Use @AutoId annotation or autoId() Java method. Auto type will determined by ORM tool to choose use which way to generate the prime key, may be Table or Sequence.
Use @TimeStampId annotation or timeStampId() Java method. This kind of prime key use current millisecondx1000000 plus a increment value as prime key.
Use sortedUUIDGenerator() java method, there is no Annotation for this prime key generator. To configure it, use:
tableModel.sortedUUIDGenerator("sortedId1", 5, 20);
table.column("id").STRING(20).pkey().idGenerator("sortedId1");
SortedUUID can build below format prime keys:
10001nmpqhegly8eozssq2p1b
10002dligkilfiskjf23klsdf
10003lvbifi35dfjia31kdsfg
If a column be configured as a prime key by use @Id or @PKey annotation but no generator be configured, jDialects do nothing to this column, i.e., jDialects believe this column's value will be filled by out side program.