Search in sources :

Example 6 with TableModel

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

the class DDLTest method testANormalModel.

@Test
public void testANormalModel() {
    // A normal setting
    TableModel t = new TableModel("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);
    testOnCurrentRealDatabase(t);
}
Also used : TableModel(com.github.drinkjava2.jdialects.model.TableModel) Test(org.junit.Test)

Example 7 with TableModel

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

the class DDLTest method testEngineTailAndColumnTail.

@Test
public void testEngineTailAndColumnTail() {
    // engineTail and column Tail
    TableModel t = new TableModel("tailsTestTable");
    t.engineTail(" DEFAULT CHARSET=utf8");
    t.column("id").STRING(20).pkey();
    t.column("name").STRING(20).tail(" default 'hahaha'");
    printOneDialectsDDLs(Dialect.Oracle10gDialect, t);
    printOneDialectsDDLs(Dialect.H2Dialect, t);
    printOneDialectsDDLs(Dialect.MySQL5InnoDBDialect, t);
    printOneDialectsDDLs(Dialect.MariaDB53Dialect, t);
    testOnCurrentRealDatabase(t);
}
Also used : TableModel(com.github.drinkjava2.jdialects.model.TableModel) Test(org.junit.Test)

Example 8 with TableModel

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

the class DDLTest method allowNullModel.

private static TableModel allowNullModel() {
    // Allow Null
    TableModel t = new TableModel("testTable");
    t.column("b1").BOOLEAN();
    t.column("d2").DOUBLE();
    t.column("f3").FLOAT(5);
    t.column("i4").INTEGER();
    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);
    return t;
}
Also used : TableModel(com.github.drinkjava2.jdialects.model.TableModel)

Example 9 with TableModel

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

the class DDLTest method autoGeneratorModel2.

private static TableModel autoGeneratorModel2() {
    // autoGenerator
    TableModel t = new TableModel("testTable2");
    t.tableGenerator("tbgen7", "tb1", "pkcol4", "valcol", "pkval5", 1, 10);
    t.column("i1").INTEGER().pkey().autoId();
    t.column("i2").INTEGER().autoId();
    t.column("i3").INTEGER().autoId();
    return t;
}
Also used : TableModel(com.github.drinkjava2.jdialects.model.TableModel)

Example 10 with TableModel

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

the class DDLTest method checkModel.

private static TableModel checkModel() {
    // column check
    TableModel t = new TableModel("testTable");
    t.column("s1").STRING(20).notNull().check("s1>5");
    t.column("s2").STRING(20).check("s2>5");
    t.column("s3").STRING(20).notNull().check("s3>5");
    t.column("s4").STRING(20).check("s4>5");
    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