mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 00:24:57 +00:00
HHH-15212 Fix SimpleAuxiliaryDatabaseObject ignoring the default catalog/schema set through configuration properties
This commit is contained in:
parent
eab669f04e
commit
d28e300013
@ -78,7 +78,7 @@ public SimpleAuxiliaryDatabaseObject(
|
||||
public String[] sqlCreateStrings(SqlStringGenerationContext context) {
|
||||
final String[] copy = new String[createStrings.length];
|
||||
for ( int i = 0, max =createStrings.length; i<max; i++ ) {
|
||||
copy[i] = injectCatalogAndSchema( createStrings[i] );
|
||||
copy[i] = injectCatalogAndSchema( createStrings[i], context );
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
@ -87,7 +87,7 @@ public String[] sqlCreateStrings(SqlStringGenerationContext context) {
|
||||
public String[] sqlDropStrings(SqlStringGenerationContext context) {
|
||||
final String[] copy = new String[dropStrings.length];
|
||||
for ( int i = 0, max = dropStrings.length; i<max; i++ ) {
|
||||
copy[i] = injectCatalogAndSchema( dropStrings[i] );
|
||||
copy[i] = injectCatalogAndSchema( dropStrings[i], context );
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
@ -100,9 +100,11 @@ protected String getSchemaName() {
|
||||
return schemaName;
|
||||
}
|
||||
|
||||
private String injectCatalogAndSchema(String ddlString) {
|
||||
String rtn = StringHelper.replace( ddlString, CATALOG_NAME_PLACEHOLDER, catalogName == null ? "" : catalogName );
|
||||
rtn = StringHelper.replace( rtn, SCHEMA_NAME_PLACEHOLDER, schemaName == null ? "" : schemaName );
|
||||
private String injectCatalogAndSchema(String ddlString, SqlStringGenerationContext context) {
|
||||
Identifier defaultedCatalogName = context.catalogWithDefault( catalogName == null ? null : context.toIdentifier( catalogName ) );
|
||||
Identifier defaultedSchemaName = context.schemaWithDefault( schemaName == null ? null : context.toIdentifier( schemaName ) );
|
||||
String rtn = StringHelper.replace( ddlString, CATALOG_NAME_PLACEHOLDER, defaultedCatalogName == null ? "" : defaultedCatalogName.getText() );
|
||||
rtn = StringHelper.replace( rtn, SCHEMA_NAME_PLACEHOLDER, defaultedSchemaName == null ? "" : defaultedSchemaName.getText() );
|
||||
return rtn;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,25 @@ public interface SqlStringGenerationContext {
|
||||
* @return The helper for dealing with identifiers in the current JDBC environment.
|
||||
* <p>
|
||||
* Note that the Identifiers returned from this helper already account for auto-quoting.
|
||||
*
|
||||
* @deprecated Use {@link #toIdentifier(String)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
IdentifierHelper getIdentifierHelper();
|
||||
|
||||
/**
|
||||
* Generate an Identifier instance from its simple name as obtained from mapping
|
||||
* information.
|
||||
* <p/>
|
||||
* Note that Identifiers returned from here may be implicitly quoted based on
|
||||
* 'globally quoted identifiers' or based on reserved words.
|
||||
*
|
||||
* @param text The text form of a name as obtained from mapping information.
|
||||
*
|
||||
* @return The identifier form of the name.
|
||||
*/
|
||||
Identifier toIdentifier(String text);
|
||||
|
||||
/**
|
||||
* @return The default catalog, used for table/sequence names that do not explicitly mention a catalog.
|
||||
* May be {@code null}.
|
||||
|
@ -114,6 +114,11 @@ public IdentifierHelper getIdentifierHelper() {
|
||||
return identifierHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier toIdentifier(String text) {
|
||||
return identifierHelper != null ? identifierHelper.toIdentifier( text ) : Identifier.toIdentifier( text );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getDefaultCatalog() {
|
||||
return defaultCatalog;
|
||||
|
Loading…
x
Reference in New Issue
Block a user