use of com.github.drinkjava2.jdialects.model.TableModel 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));
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class IdgeneratorTest method testUUIDs.
@Test
public void testUUIDs() {
// nextID
TableModel t = new TableModel("testNextIdTable");
t.column("id1").STRING(25).pkey();
t.column("id2").STRING(32);
t.column("id3").STRING(36);
String[] ddls = guessedDialect.toDropDDL(t);
quietExecuteDDLs(ddls);
ddls = guessedDialect.toCreateDDL(t);
executeDDLs(ddls);
for (int i = 0; i < 10; i++) {
Object id1 = guessedDialect.getNexID(UUID25Generator.INSTANCE, dbPro, null);
Object id2 = guessedDialect.getNexID(UUID32Generator.INSTANCE, dbPro, null);
Object id3 = guessedDialect.getNexID(UUID36Generator.INSTANCE, dbPro, null);
System.out.println(id1);
System.out.println(id2);
System.out.println(id3);
Assert.assertTrue(("" + id1).length() == 25);
Assert.assertTrue(("" + id2).length() == 32);
Assert.assertTrue(("" + id3).length() == 36);
dbPro.nExecute("insert into testNextIdTable (id1,id2,id3) values(?,?,?) ", id1, id2, id3);
}
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class IdgeneratorTest method testPKey.
@Test
public void testPKey() {
// nextID
TableModel t = new TableModel("testPKey");
t.column("id1").STRING(25).pkey();
Assert.assertTrue(t.column("id1").getPkey());
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class IdgeneratorTest method testAutoIdGenerator.
@Test
public void testAutoIdGenerator() {
TableModel table = new TableModel("testAutoIdGenerator");
table.column("id").STRING(30).pkey().autoId();
reBuildDB(table);
IdGenerator gen = table.getColumn("id").getIdGenerator();
for (int i = 0; i < 5; i++) System.out.println(gen.getNextID(dbPro, guessedDialect, null));
gen = AutoIdGenerator.INSTANCE;
for (int i = 0; i < 5; i++) System.out.println(gen.getNextID(dbPro, guessedDialect, null));
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class IdgeneratorTest method testPKey2.
@Test
public void testPKey2() {
// nextID
TableModel t = TableModelUtils.entity2Model(pkeyEntity.class);
Assert.assertTrue(t.column("id1").getPkey());
Assert.assertTrue(t.column("id2").getPkey());
}
Aggregations