Class ConnectedQueryBuilder
- java.lang.Object
-
- jetbrains.buildServer.serverSide.db.schema.QueryBuilder
-
- jetbrains.buildServer.serverSide.db.schema.ConnectedQueryBuilder
-
public final class ConnectedQueryBuilder extends QueryBuilder
Use this query builder with overloaded methods if the instance is supposed to be short-lived (e. g.: stored in a local variable), so that there's little chance that the underlying database connection is interrupted. Otherwise, use the base implementation whose methods additionally accept an instance of
DBFunctions
.- Since:
- 2017.2.1
- Author:
- Andrey Shcheglov <mailto:andrey.shcheglov@jetbrains.com>
- See Also:
QueryBuilder
,DBFunctions
-
-
Constructor Summary
Constructors Constructor Description ConnectedQueryBuilder(DBFunctions dbf)
Creates a new query builder with a persistent underlying database connection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
buildSchema(DBFunctions dbf, SchemaDef schemaDef)
Generates schema from schemaDef, without commitString[]
genCreateBackupTables(SchemaDef schema, String suffix)
Generates the DDL for all tables in theschema
, withsuffix
appended to the name of each table.String[]
genCreateSchemaCompletely(SchemaDef schema)
Generates the complete DDL script for creating a database.String[]
genCreateTableCompletely(TableDef table)
Generates the DDL statement(s) for creating the specified table along with its keys and indices (if any).String[]
genCreateTablesOnly(SchemaDef schema, Set<String> tableNames)
Generates the DDL script for creating tables without indices (if any).String[]
genPerSessionScript(SchemaDef schema)
Generates the DDL script that should be executed at the beginning of each database session.-
Methods inherited from class jetbrains.buildServer.serverSide.db.schema.QueryBuilder
genCreateKey, genCreateSchemaCompletely, genCreateTableCompletely, genPerSessionScript, genSelectionStringRepresentationOfSeveralFields, makeDataTypeSpec, makeNullability
-
-
-
-
Constructor Detail
-
ConnectedQueryBuilder
public ConnectedQueryBuilder(@NotNull DBFunctions dbf)
Creates a new query builder with a persistent underlying database connection.
- Parameters:
dbf
- the database connection.
-
-
Method Detail
-
buildSchema
public static void buildSchema(@NotNull DBFunctions dbf, @NotNull SchemaDef schemaDef)
Generates schema from schemaDef, without commit- Parameters:
dbf
-schemaDef
-- Since:
- 2018.2
-
genCreateSchemaCompletely
@NotNull public String[] genCreateSchemaCompletely(@NotNull SchemaDef schema)
Generates the complete DDL script for creating a database. Key and index definitions are inlined if possible. Temporary tables are included if they are permanent.
- Parameters:
schema
- the definition of the schema to generate.- Returns:
- the generated DDL statements.
- See Also:
QueryBuilder.genCreateSchemaCompletely(SchemaDef, DBFunctions)
-
genPerSessionScript
@NotNull public String[] genPerSessionScript(@NotNull SchemaDef schema)
Generates the DDL script that should be executed at the beginning of each database session.
- Parameters:
schema
- the schema definition to extract temporary table definitions from.- Returns:
- the generated DDL statements.
- See Also:
QueryBuilder.genPerSessionScript(SchemaDef, DBFunctions)
-
genCreateTablesOnly
@NotNull public String[] genCreateTablesOnly(@NotNull SchemaDef schema, @NotNull Set<String> tableNames)
Generates the DDL script for creating tables without indices (if any). For permanent tables, only clustered key definitions are issued. For temporary tables, all key and index definitions (if any) are issued.
- Parameters:
schema
- the schema definition to extract table definitions from.tableNames
- the extra filter on the tables contained byschema
(only the intersection ofschema
andtableNames
is processed). IftableNames
is empty, an empty array is returned.- Returns:
- the generated DDL statements.
- See Also:
QueryBuilder.genCreateTablesOnly(SchemaDef, Set, DBFunctions)
-
genCreateBackupTables
@NotNull public String[] genCreateBackupTables(@NotNull SchemaDef schema, @NotNull String suffix)
Generates the DDL for all tables in the
schema
, withsuffix
appended to the name of each table.- Parameters:
schema
- the schema definition to extract table definitions from.suffix
- the suffix to append to the name of the table, or an empty string if table name transformation is not required.- Returns:
- the generated DDL statements.
- See Also:
QueryBuilder.genCreateBackupTables(SchemaDef, String, DBFunctions)
-
genCreateTableCompletely
@NotNull public String[] genCreateTableCompletely(@NotNull TableDef table)
Generates the DDL statement(s) for creating the specified table along with its keys and indices (if any). If the table contains no keys or indices or their definitions can be inlined, only a single DDL statement is returned.
- Parameters:
table
- the definition of the table to generate.- Returns:
- the generated DDL statement(s).
- See Also:
QueryBuilder.genCreateTableCompletely(TableDef, DBFunctions)
-
-