Search in sources :

Example 6 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method CommentModel.

private static Table CommentModel() {
    // Comment
    Table t = new Table("testTable").comment("table_comment");
    t.column("s1").INTEGER().unique().notNull().identity().pkey();
    t.column("s2").LONG().comment("column_comment1");
    t.column("s3").BIGINT().comment("column_comment2");
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 7 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method printAllDialectsDDLs.

private static void printAllDialectsDDLs(Table... tables) {
    Dialect[] diaList = Dialect.values();
    for (Dialect dialect : diaList) {
        System.out.println("======" + dialect + "=====");
        try {
            String[] ddl = dialect.toCreateDDL(tables);
            printDDLs(ddl);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Exception found: " + e.getMessage());
        }
    }
}
Also used : Dialect(com.github.drinkjava2.jdialects.Dialect)

Example 8 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method testANormalModel.

@Test
public void testANormalModel() {
    // A normal setting
    Table t = new Table("testTable");
    t.column("b1").BOOLEAN();
    t.column("d2").DOUBLE();
    t.column("f3").FLOAT(5);
    t.column("i4").INTEGER().pkey();
    t.column("l5").LONG();
    t.column("s6").SHORT();
    t.column("b7").BIGDECIMAL(10, 2);
    t.column("s8").STRING(20);
    t.column("d9").DATE();
    t.column("t10").TIME();
    t.column("t11").TIMESTAMP();
    t.column("v12").VARCHAR(300);
    printAllDialectsDDLs(t);
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table) Test(org.junit.Test)

Example 9 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class TableTest method testNoPkey.

@Test
public void testNoPkey() {
    // Test no Prime Key
    // append() is a linked method
    Table table = new Table("tb").append(new Column("field1").INTEGER()).append(new Column("field2").LONG());
    printAllDialectsDDLs(table);
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table) Column(com.github.drinkjava2.jdialects.model.Column) Test(org.junit.Test)

Example 10 with Table

use of com.github.drinkjava2.jdialects.model.Table in project jDialects by drinkjava2.

the class DDLTest method testNoPkey.

@Test
public void testNoPkey() {
    // Test no Prime Key
    // append() is a linked method
    TableModel t = new TableModel("aa");
    t.addColumn(new ColumnModel("aaaa"));
    TableModel table = new TableModel("tb").addColumn(new ColumnModel("field1").INTEGER()).addColumn(new ColumnModel("field2").LONG());
    printAllDialectsDDLs(table);
    testOnCurrentRealDatabase(table);
}
Also used : ColumnModel(com.github.drinkjava2.jdialects.model.ColumnModel) TableModel(com.github.drinkjava2.jdialects.model.TableModel) Test(org.junit.Test)

Aggregations

Table (com.github.drinkjava2.jdialects.model.Table)18 Test (org.junit.Test)10 TableModel (com.github.drinkjava2.jdialects.model.TableModel)9 ColumnModel (com.github.drinkjava2.jdialects.model.ColumnModel)8 AutoIdGenerator (com.github.drinkjava2.jdialects.id.AutoIdGenerator)7 IdGenerator (com.github.drinkjava2.jdialects.id.IdGenerator)7 TableIdGenerator (com.github.drinkjava2.jdialects.id.TableIdGenerator)6 FKeyModel (com.github.drinkjava2.jdialects.model.FKeyModel)6 SequenceIdGenerator (com.github.drinkjava2.jdialects.id.SequenceIdGenerator)4 ArrayList (java.util.ArrayList)4 Dialect (com.github.drinkjava2.jdialects.Dialect)3 FKeyConstraint (com.github.drinkjava2.jdialects.model.FKeyConstraint)3 UniqueModel (com.github.drinkjava2.jdialects.model.UniqueModel)3 DB2400Dialect (com.github.drinkjava2.jdialects.Dialect.DB2400Dialect)2 DB2Dialect (com.github.drinkjava2.jdialects.Dialect.DB2Dialect)2 DerbyDialect (com.github.drinkjava2.jdialects.Dialect.DerbyDialect)2 DerbyTenFiveDialect (com.github.drinkjava2.jdialects.Dialect.DerbyTenFiveDialect)2 DerbyTenSevenDialect (com.github.drinkjava2.jdialects.Dialect.DerbyTenSevenDialect)2 DerbyTenSixDialect (com.github.drinkjava2.jdialects.Dialect.DerbyTenSixDialect)2 H2Dialect (com.github.drinkjava2.jdialects.Dialect.H2Dialect)2