public class CreateH2DdlFromSchemaDef extends H2SqlPart
Generates H2 DDL from SchemaDef
DROP TABLE IF EXISTS table_name;
CREATE TABLE IF NOT EXISTS table_name (
user_id bigint,
email text,
PRIMARY KEY (user_id)
);
CREATE INDEX idx_email ON table_name (email);
ALTER TABLE foreign_table_name
ADD CONSTRAINT fk_constraint_name FOREIGN KEY(fk_field_name)
REFERENCES primary_table_name (pk_field_name)
ON DELETE CASCADE
ON UPDATE RESTRICT;
| Constructor and Description |
|---|
CreateH2DdlFromSchemaDef(SchemaDef schemaDef) |
| Modifier and Type | Method and Description |
|---|---|
void |
collectSqlFragment(CodeWriter writer)
Generates DDL from
schemaDef and writes the output to writer. |
Integer |
getDefaultBigDecimalPrecision()
Returns the default precision of
FieldType.BIG_DECIMAL (default 20). |
Integer |
getDefaultBigDecimalScale()
Sets the default scale of
FieldType.BIG_DECIMAL (default 5). |
Integer |
getDefaultBigIntegerPrecision()
Returns the default precision of
FieldType.BIG_INTEGER (default 20). |
List<String> |
getEntityNames()
Returns entity names that are specified by
setEntityNames(java.util.List<java.lang.String>) to be included in the output DDL. |
SchemaDef |
getSchemaDef()
Returns provided
schemaDef. |
boolean |
isCheckIfDropTableExists()
Indicates if
IF EXISTS clause should be included in the DROP TABLE statement (default is true). |
boolean |
isCheckIfTableNotExists()
Indicates if
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default is true). |
boolean |
isDropTable()
Indicates if drop table statement should be included in the output DDL for each entity
in the
schemaDef (default true). |
boolean |
isGenerateIndexes()
Indicates if DDL should be generated for indexes in the
schemaDef (default is true). |
boolean |
isGenerateRelationships()
Indicates if DDL should be generated for relationships in the
schemaDef (default is true). |
CreateH2DdlFromSchemaDef |
setCheckIfDropTableExists(boolean checkIfDropTableExists)
Indicates if
IF EXISTS clause should be included in the DROP TABLE statement (default is true). |
CreateH2DdlFromSchemaDef |
setCheckIfTableNotExists(boolean checkIfTableNotExists)
Indicates if
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default is true). |
CreateH2DdlFromSchemaDef |
setDefaultBigDecimalPrecision(int defaultBigDecimalPrecision)
Sets a default precision for
FieldType.BIG_DECIMAL.This value will be used if no precision is specified for BIG_DECIMAL fields (default 20). |
CreateH2DdlFromSchemaDef |
setDefaultBigDecimalScale(Integer defaultBigDecimalScale)
Sets a default scale for
FieldType.BIG_DECIMAL (default 5).This value will be used if no scale is specified for BIG_DECIMAL fields. |
CreateH2DdlFromSchemaDef |
setDefaultBigIntegerPrecision(int defaultBigIntegerPrecision)
Sets a default precision for
FieldType.BIG_INTEGER (default 20).This value will be used if no precision is specified for BIG_INTEGER fields. |
CreateH2DdlFromSchemaDef |
setDropTable(boolean dropTable)
Indicates if drop table statement should be included in the output DDL for each entity
in the
schemaDef (default true). |
CreateH2DdlFromSchemaDef |
setEntityNames(List<String> entityNames)
Set entity names that should be included in the output DDL (all entities will be included by default).
|
CreateH2DdlFromSchemaDef |
setEntityNames(String... entityNames)
Set entity names that should be included in the output DDL (all entities will be included by default).
|
CreateH2DdlFromSchemaDef |
setGenerateIndexes(boolean generateIndexes)
Indicates if DDL should be generated for indexes in the
schemaDef (default is true). |
CreateH2DdlFromSchemaDef |
setGenerateRelationships(boolean generateRelationships)
Indicates if DDL should be generated for indexes in the
schemaDef (default is true). |
CreateH2DdlFromSchemaDef |
setPretty(boolean pretty)
Indicates if line breaks and indentations should be added to output DDL (default false).
Example output (pretty = true):
CREATE TABLE IF NOT EXISTS table_name (
Example output (pretty = false): CREATE TABLE IF NOT EXISTS table_name (id bigint, email text, PRIMARY KEY (user_id)); |
escapeKeyword, placeBackTickscollectParameterValues, getParameterValues, getSqlFragment, isPretty, printSqlParts, toStringpublic CreateH2DdlFromSchemaDef(SchemaDef schemaDef)
public void collectSqlFragment(CodeWriter writer)
schemaDef and writes the output to writer.collectSqlFragment in class SqlPartpublic boolean isGenerateIndexes()
schemaDef (default is true).public CreateH2DdlFromSchemaDef setGenerateIndexes(boolean generateIndexes)
schemaDef (default is true).public boolean isGenerateRelationships()
schemaDef (default is true).public CreateH2DdlFromSchemaDef setGenerateRelationships(boolean generateRelationships)
schemaDef (default is true).public boolean isCheckIfTableNotExists()
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default is true).public CreateH2DdlFromSchemaDef setCheckIfTableNotExists(boolean checkIfTableNotExists)
IF NOT EXISTS clause should be included in the CREATE TABLE statement (default is true).public boolean isCheckIfDropTableExists()
IF EXISTS clause should be included in the DROP TABLE statement (default is true).public CreateH2DdlFromSchemaDef setCheckIfDropTableExists(boolean checkIfDropTableExists)
IF EXISTS clause should be included in the DROP TABLE statement (default is true).public List<String> getEntityNames()
setEntityNames(java.util.List<java.lang.String>) to be included in the output DDL.public CreateH2DdlFromSchemaDef setEntityNames(List<String> entityNames)
Set entity names that should be included in the output DDL (all entities will be included by default).
entityNames will be excluded from the generated SQL including relationships
that involve any of them.public CreateH2DdlFromSchemaDef setEntityNames(String... entityNames)
Set entity names that should be included in the output DDL (all entities will be included by default).
entityNames will be excluded from the generated SQL including relationships
that involve any of them.public CreateH2DdlFromSchemaDef setPretty(boolean pretty)
CREATE TABLE IF NOT EXISTS table_name (
id bigint,
email text
PRIMARY KEY (user_id)
);
CREATE TABLE IF NOT EXISTS table_name (id bigint, email text, PRIMARY KEY (user_id));public boolean isDropTable()
schemaDef (default true).public CreateH2DdlFromSchemaDef setDropTable(boolean dropTable)
schemaDef (default true).public Integer getDefaultBigIntegerPrecision()
FieldType.BIG_INTEGER (default 20).public CreateH2DdlFromSchemaDef setDefaultBigIntegerPrecision(int defaultBigIntegerPrecision)
FieldType.BIG_INTEGER (default 20).BIG_INTEGER fields.public Integer getDefaultBigDecimalPrecision()
FieldType.BIG_DECIMAL (default 20).public CreateH2DdlFromSchemaDef setDefaultBigDecimalPrecision(int defaultBigDecimalPrecision)
FieldType.BIG_DECIMAL.BIG_DECIMAL fields (default 20).public Integer getDefaultBigDecimalScale()
FieldType.BIG_DECIMAL (default 5).public CreateH2DdlFromSchemaDef setDefaultBigDecimalScale(Integer defaultBigDecimalScale)
FieldType.BIG_DECIMAL (default 5).BIG_DECIMAL fields.Copyright (c) 2006-2026 North Concepts Inc. All Rights Reserved.