Search in sources :

Example 21 with TableModel

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

Example 22 with TableModel

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

Example 23 with TableModel

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

Example 24 with TableModel

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

Example 25 with TableModel

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

Aggregations

TableModel (com.github.drinkjava2.jdialects.model.TableModel)36 Test (org.junit.Test)19 ColumnModel (com.github.drinkjava2.jdialects.model.ColumnModel)11 AutoIdGenerator (com.github.drinkjava2.jdialects.id.AutoIdGenerator)9 IdGenerator (com.github.drinkjava2.jdialects.id.IdGenerator)9 SequenceIdGenerator (com.github.drinkjava2.jdialects.id.SequenceIdGenerator)5 TableIdGenerator (com.github.drinkjava2.jdialects.id.TableIdGenerator)5 FKeyModel (com.github.drinkjava2.jdialects.model.FKeyModel)5 IndexModel (com.github.drinkjava2.jdialects.model.IndexModel)3 UniqueModel (com.github.drinkjava2.jdialects.model.UniqueModel)3 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 Dialect (com.github.drinkjava2.jdialects.Dialect)2 Connection (java.sql.Connection)2 Map (java.util.Map)2 SortedUUIDGenerator (com.github.drinkjava2.jdialects.id.SortedUUIDGenerator)1 Table (com.github.drinkjava2.jdialects.model.Table)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 BeanInfo (java.beans.BeanInfo)1 PropertyDescriptor (java.beans.PropertyDescriptor)1