HHH-12919 Interning of strings for EntityReferenceAliases

This commit is contained in:
Sanne Grinovero 2018-08-17 12:59:34 +01:00 committed by Guillaume Smet
parent 096b436f3d
commit fb54090329
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 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, String>();
}
String old = querySpaceUidToSqlTableAliasMap.put( querySpaceUid, sqlTableAlias );
String old = querySpaceUidToSqlTableAliasMap.put( safeInterning( querySpaceUid ), safeInterning( sqlTableAlias ) );
if ( old != null ) {
if ( old.equals( sqlTableAlias ) ) {
// silently ignore...

View File

@ -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;
}

View File

@ -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() {

View File

@ -138,6 +138,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