use of com.github.drinkjava2.jdialects.id.SortedUUIDGenerator in project jDialects by drinkjava2.
the class TableModel method sortedUUIDGenerator.
/**
* Add a Sequence Generator, note: not all database support sequence
*/
public void sortedUUIDGenerator(String name, Integer sortedLength, Integer uuidLength) {
DialectException.assureNotNull(name);
if (this.getIdGenerator(GenerationType.SORTED_UUID, name) != null)
throw new DialectException("Duplicated sortedUUIDGenerator name '" + name + "'");
idGenerators.add(new SortedUUIDGenerator(name, sortedLength, uuidLength));
}
use of com.github.drinkjava2.jdialects.id.SortedUUIDGenerator in project jDialects by drinkjava2.
the class IdgeneratorTest method testSortedUUIDGenerator.
@Test
public void testSortedUUIDGenerator() {
TableModel table = new TableModel("testSortedUUIDGenerator");
table.sortedUUIDGenerator("sorteduuid", 8, 8);
table.addGenerator(new SortedUUIDGenerator("sorteduuid2", 10, 10));
table.column("id").STRING(30).pkey().idGenerator("sorteduuid");
table.column("id2").STRING(30).pkey().idGenerator("sorteduuid2");
reBuildDB(table);
IdGenerator gen1 = table.getIdGenerator("sorteduuid");
for (int i = 0; i < 10; i++) System.out.println(gen1.getNextID(dbPro, guessedDialect, null));
IdGenerator gen2 = table.getIdGenerator("sorteduuid2");
for (int i = 0; i < 10; i++) System.out.println(gen2.getNextID(dbPro, guessedDialect, null));
}
Aggregations