Class SqlStringGenerationContextImpl
- java.lang.Object
-
- org.hibernate.boot.model.relational.internal.SqlStringGenerationContextImpl
-
- All Implemented Interfaces:
SqlStringGenerationContext
public class SqlStringGenerationContextImpl extends Object implements SqlStringGenerationContext
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Identifier
catalogWithDefault(Identifier explicitCatalogOrNull)
String
format(QualifiedName qualifiedName)
Render a formatted non-table and non-sequence qualified nameString
format(QualifiedSequenceName qualifiedName)
Render a formatted sequence nameString
format(QualifiedTableName qualifiedName)
Render a formatted a table nameString
formatWithoutCatalog(QualifiedSequenceName qualifiedName)
Render a formatted sequence name, without the catalog (even the default one).static SqlStringGenerationContext
forTests(JdbcEnvironment jdbcEnvironment)
static SqlStringGenerationContext
forTests(JdbcEnvironment jdbcEnvironment, String defaultCatalog, String defaultSchema)
static SqlStringGenerationContext
fromConfigurationMap(JdbcEnvironment jdbcEnvironment, Database database, Map<String,Object> configurationMap)
static SqlStringGenerationContext
fromExplicit(JdbcEnvironment jdbcEnvironment, Database database, String defaultCatalog, String defaultSchema)
Identifier
getDefaultCatalog()
Identifier
getDefaultSchema()
Dialect
getDialect()
IdentifierHelper
getIdentifierHelper()
Identifier
schemaWithDefault(Identifier explicitSchemaOrNull)
Identifier
toIdentifier(String text)
Generate an Identifier instance from its simple name as obtained from mapping information.
-
-
-
Method Detail
-
fromConfigurationMap
public static SqlStringGenerationContext fromConfigurationMap(JdbcEnvironment jdbcEnvironment, Database database, Map<String,Object> configurationMap)
- Parameters:
jdbcEnvironment
- The JDBC environment, to extract the dialect, identifier helper, etc.database
- The database metadata, to retrieve the implicit namespace name configured through XML mapping.configurationMap
- The configuration map, holding settings such as "hibernate.default_schema".- Returns:
- An
SqlStringGenerationContext
.
-
fromExplicit
public static SqlStringGenerationContext fromExplicit(JdbcEnvironment jdbcEnvironment, Database database, String defaultCatalog, String defaultSchema)
- Parameters:
jdbcEnvironment
- The JDBC environment, to extract the dialect, identifier helper, etc.database
- The database metadata, to retrieve the implicit namespace name configured through XML mapping.defaultCatalog
- The default catalog to use; ifnull
, will use the implicit catalog that was configured through XML mapping.defaultSchema
- The default schema to use; ifnull
, will use the implicit schema that was configured through XML mapping.- Returns:
- An
SqlStringGenerationContext
.
-
forTests
public static SqlStringGenerationContext forTests(JdbcEnvironment jdbcEnvironment)
-
forTests
public static SqlStringGenerationContext forTests(JdbcEnvironment jdbcEnvironment, String defaultCatalog, String defaultSchema)
-
getDialect
public Dialect getDialect()
- Specified by:
getDialect
in interfaceSqlStringGenerationContext
- Returns:
- The database dialect of the current JDBC environment, to generate SQL fragments that are specific to each vendor.
-
getIdentifierHelper
public IdentifierHelper getIdentifierHelper()
- Specified by:
getIdentifierHelper
in interfaceSqlStringGenerationContext
- Returns:
- The helper for dealing with identifiers in the current JDBC environment.
Note that the Identifiers returned from this helper already account for auto-quoting.
-
toIdentifier
public Identifier toIdentifier(String text)
Description copied from interface:SqlStringGenerationContext
Generate an Identifier instance from its simple name as obtained from mapping information. Note that Identifiers returned from here may be implicitly quoted based on 'globally quoted identifiers' or based on reserved words.- Specified by:
toIdentifier
in interfaceSqlStringGenerationContext
- Parameters:
text
- The text form of a name as obtained from mapping information.- Returns:
- The identifier form of the name.
-
getDefaultCatalog
public Identifier getDefaultCatalog()
- Specified by:
getDefaultCatalog
in interfaceSqlStringGenerationContext
- Returns:
- The default catalog, used for table/sequence names that do not explicitly mention a catalog.
May be
null
. This default is generally applied automatically by theformat methods
, but in some cases it can be useful to access it directly.
-
catalogWithDefault
public Identifier catalogWithDefault(Identifier explicitCatalogOrNull)
- Specified by:
catalogWithDefault
in interfaceSqlStringGenerationContext
- Parameters:
explicitCatalogOrNull
- An explicitly configured catalog, ornull
.- Returns:
- The given identifier if non-
null
, or the default catalog otherwise.
-
getDefaultSchema
public Identifier getDefaultSchema()
- Specified by:
getDefaultSchema
in interfaceSqlStringGenerationContext
- Returns:
- The default schema, used for table/sequence names that do not explicitly mention a schema.
May be
null
. This default is generally applied automatically by theformat methods
, but in some cases it can be useful to access it directly.
-
schemaWithDefault
public Identifier schemaWithDefault(Identifier explicitSchemaOrNull)
- Specified by:
schemaWithDefault
in interfaceSqlStringGenerationContext
- Parameters:
explicitSchemaOrNull
- An explicitly configured schema, ornull
.- Returns:
- The given identifier if non-
null
, or the default schema otherwise.
-
format
public String format(QualifiedTableName qualifiedName)
Description copied from interface:SqlStringGenerationContext
Render a formatted a table name- Specified by:
format
in interfaceSqlStringGenerationContext
- Parameters:
qualifiedName
- The table name- Returns:
- The formatted name,
-
format
public String format(QualifiedSequenceName qualifiedName)
Description copied from interface:SqlStringGenerationContext
Render a formatted sequence name- Specified by:
format
in interfaceSqlStringGenerationContext
- Parameters:
qualifiedName
- The sequence name- Returns:
- The formatted name
-
format
public String format(QualifiedName qualifiedName)
Description copied from interface:SqlStringGenerationContext
Render a formatted non-table and non-sequence qualified name- Specified by:
format
in interfaceSqlStringGenerationContext
- Parameters:
qualifiedName
- The name- Returns:
- The formatted name
-
formatWithoutCatalog
public String formatWithoutCatalog(QualifiedSequenceName qualifiedName)
Description copied from interface:SqlStringGenerationContext
Render a formatted sequence name, without the catalog (even the default one).- Specified by:
formatWithoutCatalog
in interfaceSqlStringGenerationContext
- Parameters:
qualifiedName
- The sequence name- Returns:
- The formatted name
-
-