final Table table = new Table("t_test") //
.addAttribute(new TableAttribute("pk", TableAttributeType.INT).setPrimaryKey(true).setGenerated(true))//
.addAttribute(new TableAttribute("counter", TableAttributeType.INT)) //
.addAttribute(new TableAttribute("money", TableAttributeType.DECIMAL, 8, 2).setNullable(false)) //
.addAttribute(new TableAttribute("address_fk", TableAttributeType.INT).setForeignTable(AddressDO.class));
final UpdaterConfiguration config = new UpdaterConfiguration();
config.setDialect(DatabaseDialect.HSQL);
final MyDatabaseUpdateDao dao = new MyDatabaseUpdateDao(config);
StringBuffer buf = new StringBuffer();
dao.buildCreateTableStatement(buf, table);
assertEquals("CREATE TABLE t_test (\n" //
+ " pk INT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) NOT NULL PRIMARY KEY,\n" //
+ " counter INT,\n" //
+ " money DECIMAL(8, 2) NOT NULL,\n" //
+ " address_fk INT,\n" //
+ " FOREIGN KEY (address_fk) REFERENCES T_ADDRESS(pk)\n" //
+ ");\n", buf.toString());
config.setDialect(DatabaseDialect.PostgreSQL);
buf = new StringBuffer();
dao.buildCreateTableStatement(buf, table);
assertEquals("CREATE TABLE t_test (\n" //
+ " pk INT4,\n" //
+ " counter INT4,\n" //