diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/relational/NamedAuxiliaryDatabaseObject.java b/hibernate-core/src/main/java/org/hibernate/boot/model/relational/NamedAuxiliaryDatabaseObject.java index 887300e3d6..9d9eb11c57 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/relational/NamedAuxiliaryDatabaseObject.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/relational/NamedAuxiliaryDatabaseObject.java @@ -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(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/relational/SimpleAuxiliaryDatabaseObject.java b/hibernate-core/src/main/java/org/hibernate/boot/model/relational/SimpleAuxiliaryDatabaseObject.java index edcaa565fc..df59ef7466 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/relational/SimpleAuxiliaryDatabaseObject.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/relational/SimpleAuxiliaryDatabaseObject.java @@ -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 ); diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java index 8e671c6cff..44c5db907b 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/ForeignKey.java @@ -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() { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Index.java b/hibernate-core/src/main/java/org/hibernate/mapping/Index.java index 7781ccceb3..4d7da83ec7 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Index.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Index.java @@ -238,6 +238,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() ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java index bcc9cd2448..3c5e9a03b1 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/PrimaryKey.java @@ -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() ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java b/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java index c85a6847f7..b3ff9fdf5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/UniqueKey.java @@ -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() ); } }