Search in sources :

Example 1 with SortedUUIDGenerator

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));
}
Also used : DialectException(com.github.drinkjava2.jdialects.DialectException) SortedUUIDGenerator(com.github.drinkjava2.jdialects.id.SortedUUIDGenerator)

Example 2 with SortedUUIDGenerator

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));
}
Also used : SortedUUIDGenerator(com.github.drinkjava2.jdialects.id.SortedUUIDGenerator) AutoIdGenerator(com.github.drinkjava2.jdialects.id.AutoIdGenerator) IdGenerator(com.github.drinkjava2.jdialects.id.IdGenerator) TableModel(com.github.drinkjava2.jdialects.model.TableModel) Test(org.junit.Test)

Aggregations

SortedUUIDGenerator (com.github.drinkjava2.jdialects.id.SortedUUIDGenerator)2 DialectException (com.github.drinkjava2.jdialects.DialectException)1 AutoIdGenerator (com.github.drinkjava2.jdialects.id.AutoIdGenerator)1 IdGenerator (com.github.drinkjava2.jdialects.id.IdGenerator)1 TableModel (com.github.drinkjava2.jdialects.model.TableModel)1 Test (org.junit.Test)1