HHH-14922 Give precedence to default catalog/schema over implicit catalog/schema
This commit is contained in:
parent
30e3aa4e7f
commit
37d3b66ce4
|
@ -41,8 +41,8 @@ public class SqlStringGenerationContextImpl
|
|||
/**
|
||||
* @param jdbcEnvironment The JDBC environment, to extract the dialect, identifier helper, etc.
|
||||
* @param database The database metadata, to retrieve the implicit namespace name configured through XML mapping.
|
||||
* @param defaultCatalog The default catalog to use, unless an implicit catalog was configured through XML mapping.
|
||||
* @param defaultSchema The default schema to use, unless an implicit schema was configured through XML mapping.
|
||||
* @param defaultCatalog The default catalog to use; if {@code null}, will use the implicit catalog that was configured through XML mapping.
|
||||
* @param defaultSchema The default schema to use; if {@code null}, will use the implicit schema that was configured through XML mapping.
|
||||
* @return An {@link SqlStringGenerationContext}.
|
||||
*/
|
||||
public static SqlStringGenerationContext fromExplicit(JdbcEnvironment jdbcEnvironment,
|
||||
|
@ -52,15 +52,17 @@ public class SqlStringGenerationContextImpl
|
|||
NameQualifierSupport nameQualifierSupport = jdbcEnvironment.getNameQualifierSupport();
|
||||
Identifier actualDefaultCatalog = null;
|
||||
if ( nameQualifierSupport.supportsCatalogs() ) {
|
||||
actualDefaultCatalog = implicitNamespaceName.getCatalog() != null
|
||||
? implicitNamespaceName.getCatalog()
|
||||
: identifierHelper.toIdentifier( defaultCatalog );
|
||||
actualDefaultCatalog = identifierHelper.toIdentifier( defaultCatalog );
|
||||
if ( actualDefaultCatalog == null ) {
|
||||
actualDefaultCatalog = implicitNamespaceName.getCatalog();
|
||||
}
|
||||
}
|
||||
Identifier actualDefaultSchema = null;
|
||||
if ( nameQualifierSupport.supportsSchemas() ) {
|
||||
actualDefaultSchema = implicitNamespaceName.getSchema() != null
|
||||
? implicitNamespaceName.getSchema()
|
||||
: identifierHelper.toIdentifier( defaultSchema );
|
||||
actualDefaultSchema = identifierHelper.toIdentifier( defaultSchema );
|
||||
if ( defaultSchema == null ) {
|
||||
actualDefaultSchema = implicitNamespaceName.getSchema();
|
||||
}
|
||||
}
|
||||
return new SqlStringGenerationContextImpl( jdbcEnvironment, actualDefaultCatalog, actualDefaultSchema );
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ public final class Settings {
|
|||
|
||||
public Settings(SessionFactoryOptions sessionFactoryOptions, String defaultCatalogName, String defaultSchemaName) {
|
||||
this.sessionFactoryOptions = sessionFactoryOptions;
|
||||
this.defaultCatalogName = defaultCatalogName != null ? defaultCatalogName : sessionFactoryOptions.getDefaultCatalog();
|
||||
this.defaultSchemaName = defaultSchemaName != null ? defaultSchemaName : sessionFactoryOptions.getDefaultSchema();
|
||||
this.defaultCatalogName = sessionFactoryOptions.getDefaultCatalog() != null ? sessionFactoryOptions.getDefaultCatalog() : defaultCatalogName;
|
||||
this.defaultSchemaName = sessionFactoryOptions.getDefaultSchema() != null ? sessionFactoryOptions.getDefaultSchema() : defaultSchemaName;
|
||||
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
LOG.debugf( "SessionFactory name : %s", sessionFactoryOptions.getSessionFactoryName() );
|
||||
|
|
|
@ -129,9 +129,9 @@ public class DefaultCatalogAndSchemaTest {
|
|||
// HHH-14922: Inconsistent precedence of orm.xml implicit catalog/schema over "default_catalog"/"default_schema"
|
||||
params.add( new Object[] { mode, "implicit-global-catalog-and-schema.orm.xml",
|
||||
"someDefaultCatalog", "someDefaultSchema",
|
||||
// The implicit catalog/schema defined in the mapping should take precedence
|
||||
// over the default catalog/schema defined in settings.
|
||||
"someImplicitCatalog", "someImplicitSchema" } );
|
||||
// The default catalog/schema should replace the
|
||||
// implicit catalog/schema defined in the mapping.
|
||||
"someDefaultCatalog", "someDefaultSchema" } );
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue