Search in sources :

Example 1 with Table

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

the class DialectTest method testDDLTypeMapping7.

@Test
public void testDDLTypeMapping7() {
    Dialect d = Dialect.MySQL5InnoDBDialect;
    String ddl = //
    "create table ddl_test(" + "f1 " + //
    d.BIGINT() + ",f2 " + //
    d.BINARY(5) + ",f3 " + //
    d.BIT() + ",f4 " + //
    d.BLOB() + ",f5 " + //
    d.BOOLEAN() + ",f6 " + //
    d.CHAR() + ",f7 " + //
    d.CLOB() + ",f8 " + //
    d.DATE() + // + ",f9 " + d.DECIMAL(3,5) //
    ",f10 " + //
    d.DOUBLE() + ",f11 " + //
    d.FLOAT() + ",f12 " + //
    d.INTEGER() + // + ",f13 " + d.JAVA_OBJECT() //
    ",f14 " + //
    d.LONGNVARCHAR(10) + ",f15 " + //
    d.LONGVARBINARY() + ",f16 " + //
    d.LONGVARCHAR() + ",f17 " + //
    d.NCHAR(5) + ",f18 " + //
    d.NCLOB() + ",f19 " + //
    d.NUMERIC(6, 4) + ",f20 " + //
    d.NVARCHAR(6) + // + ",f21 " + d.OTHER() //
    ",f22 " + //
    d.REAL() + ",f23 " + //
    d.SMALLINT() + ",f24 " + //
    d.TIME() + ",f25 " + //
    d.TIMESTAMP() + ",f26 " + //
    d.TINYINT() + ",f27 " + //
    d.VARBINARY() + ",f28 " + //
    d.VARCHAR(10) + ")" + d.engine(" DEFAULT CHARSET=utf8");
    System.out.println(ddl);
    d = Dialect.Oracle10gDialect;
    ddl = //
    "create table ddl_test(" + "f1 " + //
    d.BIGINT() + ",f2 " + //
    d.BINARY(5) + ",f3 " + //
    d.BIT() + ",f4 " + //
    d.BLOB() + ",f5 " + //
    d.BOOLEAN() + ",f6 " + //
    d.CHAR() + ",f7 " + //
    d.CLOB() + ",f8 " + //
    d.DATE() + ",f9 " + //
    d.DECIMAL(3, 5) + ",f10 " + //
    d.DOUBLE() + ",f11 " + //
    d.FLOAT() + ",f12 " + //
    d.INTEGER() + // + ",f13 " + d.JAVA_OBJECT() //
    ",f14 " + //
    d.LONGNVARCHAR(10) + ",f15 " + //
    d.LONGVARBINARY() + ",f16 " + //
    d.LONGVARCHAR() + ",f17 " + //
    d.NCHAR(5) + ",f18 " + //
    d.NCLOB() + ",f19 " + //
    d.NUMERIC(6, 4) + ",f20 " + //
    d.NVARCHAR(6) + // + ",f21 " + d.OTHER() //
    ",f22 " + //
    d.REAL() + ",f23 " + //
    d.SMALLINT() + ",f24 " + //
    d.TIME() + ",f25 " + //
    d.TIMESTAMP() + ",f26 " + //
    d.TINYINT() + ",f27 " + //
    d.VARBINARY() + ",f28 " + //
    d.VARCHAR(10) + ")" + d.engine();
    System.out.println(ddl);
}
Also used : DerbyDialect(com.github.drinkjava2.jdialects.Dialect.DerbyDialect) PostgresPlusDialect(com.github.drinkjava2.jdialects.Dialect.PostgresPlusDialect) DB2Dialect(com.github.drinkjava2.jdialects.Dialect.DB2Dialect) Dialect(com.github.drinkjava2.jdialects.Dialect) MySQLDialect(com.github.drinkjava2.jdialects.Dialect.MySQLDialect) PostgreSQL81Dialect(com.github.drinkjava2.jdialects.Dialect.PostgreSQL81Dialect) PostgreSQL9Dialect(com.github.drinkjava2.jdialects.Dialect.PostgreSQL9Dialect) Oracle10gDialect(com.github.drinkjava2.jdialects.Dialect.Oracle10gDialect) PostgreSQL82Dialect(com.github.drinkjava2.jdialects.Dialect.PostgreSQL82Dialect) SybaseASE15Dialect(com.github.drinkjava2.jdialects.Dialect.SybaseASE15Dialect) SybaseAnywhereDialect(com.github.drinkjava2.jdialects.Dialect.SybaseAnywhereDialect) DerbyTenSixDialect(com.github.drinkjava2.jdialects.Dialect.DerbyTenSixDialect) SQLServerDialect(com.github.drinkjava2.jdialects.Dialect.SQLServerDialect) HSQLDialect(com.github.drinkjava2.jdialects.Dialect.HSQLDialect) DerbyTenSevenDialect(com.github.drinkjava2.jdialects.Dialect.DerbyTenSevenDialect) H2Dialect(com.github.drinkjava2.jdialects.Dialect.H2Dialect) Oracle8iDialect(com.github.drinkjava2.jdialects.Dialect.Oracle8iDialect) Oracle9iDialect(com.github.drinkjava2.jdialects.Dialect.Oracle9iDialect) InformixDialect(com.github.drinkjava2.jdialects.Dialect.InformixDialect) SQLiteDialect(com.github.drinkjava2.jdialects.Dialect.SQLiteDialect) MySQL5Dialect(com.github.drinkjava2.jdialects.Dialect.MySQL5Dialect) DB2400Dialect(com.github.drinkjava2.jdialects.Dialect.DB2400Dialect) IngresDialect(com.github.drinkjava2.jdialects.Dialect.IngresDialect) DerbyTenFiveDialect(com.github.drinkjava2.jdialects.Dialect.DerbyTenFiveDialect) Test(org.junit.Test)

Example 2 with Table

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

the class TableTest method tableGeneratorModel2.

private static Table tableGeneratorModel2() {
    // tableGenerator
    Table t = new Table("testTable2");
    t.addTableGenerator("tbgen3", "tb1", "pkcol3", "valcol", "pkval", 1, 10);
    t.addTableGenerator("tbgen4", "tb1", "pkcol3", "valcol", "pkval2", 1, 10);
    t.addTableGenerator("tbgen5", "tb1", "pkcol4", "valcol", "pkval3", 1, 10);
    t.addTableGenerator("tbgen6", "tb1", "pkcol4", "valcol", "pkval4", 1, 10);
    t.column("i1").INTEGER().pkey().tableGenerator("tbgen1");
    t.column("i2").INTEGER().pkey().tableGenerator("tbgen2");
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 3 with Table

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

the class TableTest method IdentityModel.

private static Table IdentityModel() {
    // Identity
    Table t = new Table("testTable");
    t.check("s2>10");
    t.column("s1").INTEGER().unique().notNull().identity().pkey();
    t.column("s2").LONG().check("s2>10");
    t.column("s3").BIGINT();
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 4 with Table

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

the class TableTest method uniqueModel.

private static Table uniqueModel() {
    // unique
    Table t = new Table("testTable");
    t.column("s1").STRING(20).unique().notNull();
    t.column("s2").STRING(20).unique();
    t.column("s3").STRING(20).unique("uname1").notNull();
    t.column("s4").STRING(20).unique("uname2");
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

Example 5 with Table

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

the class TableTest method autoGeneratorModel.

private static Table autoGeneratorModel() {
    // autoGenerator
    Table t = new Table("testTable1");
    t.column("i1").INTEGER().pkey().autoGenerator();
    t.column("i2").INTEGER().autoGenerator();
    return t;
}
Also used : Table(com.github.drinkjava2.jdialects.model.Table)

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