HHH-12935 : Constraint and AuxiliaryDatabaseObject export identifiers are not qualified by schema or catalog

(cherry picked from commit 4d381457c5)
This commit is contained in:
Gail Badner 2018-08-28 22:04:44 -07:00
parent d166de919b
commit 5e8646e3bd
6 changed files with 19 additions and 5 deletions

View File

@ -8,6 +8,8 @@ package org.hibernate.boot.model.relational;
import java.util.Set;
import org.hibernate.boot.model.naming.Identifier;
/**
* Mainly this is used to support legacy sequence exporting.
*
@ -42,6 +44,10 @@ public class NamedAuxiliaryDatabaseObject
@Override
public String getExportIdentifier() {
return name;
return new QualifiedNameImpl(
Identifier.toIdentifier( getCatalogName() ),
Identifier.toIdentifier( getSchemaName() ),
Identifier.toIdentifier( name )
).render();
}
}

View File

@ -93,6 +93,14 @@ public class SimpleAuxiliaryDatabaseObject extends AbstractAuxiliaryDatabaseObje
return copy;
}
protected String getCatalogName() {
return catalogName;
}
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 );

View File

@ -33,7 +33,7 @@ public class ForeignKey extends Constraint {
@Override
public String getExportIdentifier() {
// NOt sure name is always set. Might need some implicit naming
return StringHelper.qualify( getTable().getName(), "FK-" + getName() );
return StringHelper.qualify( getTable().getExportIdentifier(), "FK-" + getName() );
}
public void disableCreation() {

View File

@ -234,6 +234,6 @@ public class Index implements RelationalModel, Exportable, Serializable {
@Override
public String getExportIdentifier() {
return StringHelper.qualify( getTable().getName(), "IDX-" + getName() );
return StringHelper.qualify( getTable().getExportIdentifier(), "IDX-" + getName() );
}
}

View File

@ -89,6 +89,6 @@ public class PrimaryKey extends Constraint {
@Override
public String getExportIdentifier() {
return StringHelper.qualify( getTable().getName(), "PK-" + getName() );
return StringHelper.qualify( getTable().getExportIdentifier(), "PK-" + getName() );
}
}

View File

@ -72,6 +72,6 @@ public class UniqueKey extends Constraint {
@Override
public String getExportIdentifier() {
return StringHelper.qualify( getTable().getName(), "UK-" + getName() );
return StringHelper.qualify( getTable().getExportIdentifier(), "UK-" + getName() );
}
}