use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class DDLTest method autoGeneratorModel.
private static TableModel autoGeneratorModel() {
// autoGenerator
TableModel t = new TableModel("testTable1");
t.column("i1").INTEGER().pkey().autoId();
t.column("i2").INTEGER().autoId();
return t;
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class DDLTest method tableGeneratorModel2.
private static TableModel tableGeneratorModel2() {
// tableGenerator
TableModel t = new TableModel("testTableGeneratorModel2");
t.tableGenerator("tbgen1", "tb1", "pkcol", "valcol", "pkval", 1, 10);
t.tableGenerator("tbgen2", "tb1", "pkcol2", "valcol", "pkval", 1, 10);
t.tableGenerator("tbgen3", "tb1", "pkcol3", "valcol", "pkval", 1, 10);
t.tableGenerator("tbgen4", "tb1", "pkcol3", "valcol", "pkval2", 1, 10);
t.tableGenerator("tbgen5", "tb1", "pkcol4", "valcol", "pkval3", 1, 10);
t.tableGenerator("tbgen6", "tb1", "pkcol4", "valcol", "pkval4", 1, 10);
t.column("i1").INTEGER().pkey().idGenerator("tbgen1");
t.column("i2").INTEGER().pkey().idGenerator("tbgen2");
return t;
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class DDLTest method singleXxxMethodTest.
@Test
public void singleXxxMethodTest() {
// Test singleXxx methods
TableModel t1 = new TableModel("customers");
t1.column("name").STRING(20).singleUnique();
t1.column("email").VARCHAR(50).defaultValue("'Beijing'").comment("address comment").singleIndex("IDX1");
TableModel t2 = new TableModel("orders");
t2.column("item").STRING(20).singleUnique("A");
t2.column("name").STRING(20).singleFKey("customers", "name");
String[] dropAndCreateDDL = Dialect.H2Dialect.toDropAndCreateDDL(t1, t2);
for (String ddl : dropAndCreateDDL) System.out.println(ddl);
testOnCurrentRealDatabase(t1, t2);
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class DDLTest method IdentityModel.
private static TableModel IdentityModel() {
// Identity
TableModel t = new TableModel("testTable");
t.check("s2>10");
t.column("s1").INTEGER().notNull().identityId().pkey();
t.column("s2").LONG().check("s2>10");
t.column("s3").BIGINT();
return t;
}
use of com.github.drinkjava2.jdialects.model.TableModel in project jDialects by drinkjava2.
the class DDLTest method uniqueModel.
private static TableModel uniqueModel() {
// unique constraint
TableModel t = new TableModel("testTable");
t.column("s1").STRING(20).singleUnique();
t.column("s2").STRING(20).notNull().singleUnique();
t.column("s3").STRING(20).singleUnique("uname1");
t.column("s4").STRING(20).notNull().singleUnique("uname2");
t.column("s5").STRING(20).singleUnique("A");
t.column("s6").STRING(20).singleUnique("A");
t.column("s7").STRING(20).notNull().singleUnique("B");
t.column("s8").STRING(20).notNull().singleUnique("B");
t.column("s9").STRING(20).singleUnique("C");
t.column("s10").STRING(20).singleUnique("D");
t.column("s11").STRING(20).notNull().singleUnique("E");
t.column("s12").STRING(20).notNull().singleUnique("F");
t.unique().columns("S9", "S10");
t.unique("uk1").columns("s11", "s12");
t.unique().columns("s5");
return t;
}
Aggregations