HHH-12919 Interning of strings for EntityReferenceAliases

(cherry picked from commit fb54090329)
This commit is contained in:
Sanne Grinovero 2018-08-17 12:59:34 +01:00 committed by Gail Badner
parent 5f7b41d54b
commit bf1f56b6bb
4 changed files with 19 additions and 9 deletions

View File

@ -34,6 +34,8 @@ import org.hibernate.type.EntityType;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import static org.hibernate.internal.util.StringHelper.safeInterning;
/** /**
* Provides aliases that are used by load queries and ResultSet processors. * Provides aliases that are used by load queries and ResultSet processors.
* *
@ -237,7 +239,7 @@ public class AliasResolutionContextImpl implements AliasResolutionContext {
if ( querySpaceUidToSqlTableAliasMap == null ) { if ( querySpaceUidToSqlTableAliasMap == null ) {
querySpaceUidToSqlTableAliasMap = new HashMap<String, String>(); querySpaceUidToSqlTableAliasMap = new HashMap<String, String>();
} }
String old = querySpaceUidToSqlTableAliasMap.put( querySpaceUid, sqlTableAlias ); String old = querySpaceUidToSqlTableAliasMap.put( safeInterning( querySpaceUid ), safeInterning( sqlTableAlias ) );
if ( old != null ) { if ( old != null ) {
if ( old.equals( sqlTableAlias ) ) { if ( old.equals( sqlTableAlias ) ) {
// silently ignore... // silently ignore...

View File

@ -9,6 +9,8 @@ package org.hibernate.loader.plan.exec.internal;
import org.hibernate.loader.EntityAliases; import org.hibernate.loader.EntityAliases;
import org.hibernate.loader.plan.exec.spi.EntityReferenceAliases; import org.hibernate.loader.plan.exec.spi.EntityReferenceAliases;
import static org.hibernate.internal.util.StringHelper.safeInterning;
/** /**
* @author Gail Badner * @author Gail Badner
* @author Steve Ebersole * @author Steve Ebersole
@ -18,7 +20,7 @@ public class EntityReferenceAliasesImpl implements EntityReferenceAliases {
private final EntityAliases columnAliases; private final EntityAliases columnAliases;
public EntityReferenceAliasesImpl(String tableAlias, EntityAliases columnAliases) { public EntityReferenceAliasesImpl(String tableAlias, EntityAliases columnAliases) {
this.tableAlias = tableAlias; this.tableAlias = safeInterning( tableAlias );
this.columnAliases = columnAliases; this.columnAliases = columnAliases;
} }

View File

@ -92,15 +92,19 @@ public class Column implements Selectable, Serializable, Cloneable {
* returns quoted name as it would be in the mapping file. * returns quoted name as it would be in the mapping file.
*/ */
public String getQuotedName() { public String getQuotedName() {
return quoted ? return safeInterning(
quoted ?
"`" + name + "`" : "`" + name + "`" :
name; name
);
} }
public String getQuotedName(Dialect d) { public String getQuotedName(Dialect d) {
return quoted ? return safeInterning(
quoted ?
d.openQuote() + name + d.closeQuote() : d.openQuote() + name + d.closeQuote() :
name; name
);
} }
@Override @Override
@ -139,7 +143,7 @@ public class Column implements Selectable, Serializable, Cloneable {
*/ */
@Override @Override
public String getAlias(Dialect dialect, Table table) { public String getAlias(Dialect dialect, Table table) {
return getAlias( dialect ) + table.getUniqueInteger() + '_'; return safeInterning( getAlias( dialect ) + table.getUniqueInteger() + '_' );
} }
public boolean isNullable() { public boolean isNullable() {
@ -342,7 +346,7 @@ public class Column implements Selectable, Serializable, Cloneable {
} }
public void setCustomWrite(String customWrite) { public void setCustomWrite(String customWrite) {
this.customWrite = customWrite; this.customWrite = safeInterning( customWrite );
} }
public String getCustomRead() { public String getCustomRead() {
@ -350,7 +354,7 @@ public class Column implements Selectable, Serializable, Cloneable {
} }
public void setCustomRead(String customRead) { public void setCustomRead(String customRead) {
this.customRead = StringHelper.nullIfEmpty( customRead ); this.customRead = safeInterning( StringHelper.nullIfEmpty( customRead ) );
} }
public String getCanonicalName() { public String getCanonicalName() {

View File

@ -139,6 +139,8 @@ import org.hibernate.type.Type;
import org.hibernate.type.TypeHelper; import org.hibernate.type.TypeHelper;
import org.hibernate.type.VersionType; import org.hibernate.type.VersionType;
import static org.hibernate.internal.util.StringHelper.safeInterning;
/** /**
* Basic functionality for persisting an entity via JDBC * Basic functionality for persisting an entity via JDBC
* through either generated or custom SQL * through either generated or custom SQL