diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AliasResolutionContextImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AliasResolutionContextImpl.java index fdd434ec84..e656ea22a8 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AliasResolutionContextImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/AliasResolutionContextImpl.java @@ -34,6 +34,8 @@ import org.hibernate.type.EntityType; import org.jboss.logging.Logger; +import static org.hibernate.internal.util.StringHelper.safeInterning; + /** * Provides aliases that are used by load queries and ResultSet processors. * @@ -237,7 +239,7 @@ public class AliasResolutionContextImpl implements AliasResolutionContext { if ( querySpaceUidToSqlTableAliasMap == null ) { querySpaceUidToSqlTableAliasMap = new HashMap(); } - String old = querySpaceUidToSqlTableAliasMap.put( querySpaceUid, sqlTableAlias ); + String old = querySpaceUidToSqlTableAliasMap.put( safeInterning( querySpaceUid ), safeInterning( sqlTableAlias ) ); if ( old != null ) { if ( old.equals( sqlTableAlias ) ) { // silently ignore... diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityReferenceAliasesImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityReferenceAliasesImpl.java index 16df015cec..2d4d87c74e 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityReferenceAliasesImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/internal/EntityReferenceAliasesImpl.java @@ -9,6 +9,8 @@ package org.hibernate.loader.plan.exec.internal; import org.hibernate.loader.EntityAliases; import org.hibernate.loader.plan.exec.spi.EntityReferenceAliases; +import static org.hibernate.internal.util.StringHelper.safeInterning; + /** * @author Gail Badner * @author Steve Ebersole @@ -18,7 +20,7 @@ public class EntityReferenceAliasesImpl implements EntityReferenceAliases { private final EntityAliases columnAliases; public EntityReferenceAliasesImpl(String tableAlias, EntityAliases columnAliases) { - this.tableAlias = tableAlias; + this.tableAlias = safeInterning( tableAlias ); this.columnAliases = columnAliases; } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java index 6cd81c90c0..4f75b98a49 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Column.java @@ -92,15 +92,19 @@ public class Column implements Selectable, Serializable, Cloneable { * returns quoted name as it would be in the mapping file. */ public String getQuotedName() { - return quoted ? + return safeInterning( + quoted ? "`" + name + "`" : - name; + name + ); } public String getQuotedName(Dialect d) { - return quoted ? + return safeInterning( + quoted ? d.openQuote() + name + d.closeQuote() : - name; + name + ); } @Override @@ -139,7 +143,7 @@ public class Column implements Selectable, Serializable, Cloneable { */ @Override public String getAlias(Dialect dialect, Table table) { - return getAlias( dialect ) + table.getUniqueInteger() + '_'; + return safeInterning( getAlias( dialect ) + table.getUniqueInteger() + '_' ); } public boolean isNullable() { @@ -342,7 +346,7 @@ public class Column implements Selectable, Serializable, Cloneable { } public void setCustomWrite(String customWrite) { - this.customWrite = customWrite; + this.customWrite = safeInterning( customWrite ); } public String getCustomRead() { @@ -350,7 +354,7 @@ public class Column implements Selectable, Serializable, Cloneable { } public void setCustomRead(String customRead) { - this.customRead = StringHelper.nullIfEmpty( customRead ); + this.customRead = safeInterning( StringHelper.nullIfEmpty( customRead ) ); } public String getCanonicalName() { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index d22ffe8eb0..21ef9cf37c 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -139,6 +139,8 @@ import org.hibernate.type.Type; import org.hibernate.type.TypeHelper; import org.hibernate.type.VersionType; +import static org.hibernate.internal.util.StringHelper.safeInterning; + /** * Basic functionality for persisting an entity via JDBC * through either generated or custom SQL