HHH-12918 Interning of strings for Formula and Column exctraction templates

This commit is contained in:
Sanne Grinovero 2018-08-17 12:41:08 +01:00 committed by Guillaume Smet
parent 4fa0491341
commit 096b436f3d
2 changed files with 9 additions and 3 deletions

View File

@ -17,6 +17,8 @@ import org.hibernate.engine.spi.Mapping;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.sql.Template; import org.hibernate.sql.Template;
import static org.hibernate.internal.util.StringHelper.safeInterning;
/** /**
* A column of a relational database table * A column of a relational database table
* *
@ -268,10 +270,12 @@ public class Column implements Selectable, Serializable, Cloneable {
@Override @Override
public String getTemplate(Dialect dialect, SQLFunctionRegistry functionRegistry) { public String getTemplate(Dialect dialect, SQLFunctionRegistry functionRegistry) {
return hasCustomRead() return safeInterning(
hasCustomRead()
// see note in renderTransformerReadFragment wrt access to SessionFactory // see note in renderTransformerReadFragment wrt access to SessionFactory
? Template.renderTransformerReadFragment( customRead, getQuotedName( dialect ) ) ? Template.renderTransformerReadFragment( customRead, getQuotedName( dialect ) )
: Template.TEMPLATE + '.' + getQuotedName( dialect ); : Template.TEMPLATE + '.' + getQuotedName( dialect )
);
} }
public boolean hasCustomRead() { public boolean hasCustomRead() {

View File

@ -13,6 +13,8 @@ import org.hibernate.dialect.function.SQLFunctionRegistry;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.sql.Template; import org.hibernate.sql.Template;
import static org.hibernate.internal.util.StringHelper.safeInterning;
/** /**
* A formula is a derived column value * A formula is a derived column value
* @author Gavin King * @author Gavin King
@ -35,7 +37,7 @@ public class Formula implements Selectable, Serializable {
@Override @Override
public String getTemplate(Dialect dialect, SQLFunctionRegistry functionRegistry) { public String getTemplate(Dialect dialect, SQLFunctionRegistry functionRegistry) {
String template = Template.renderWhereStringTemplate(formula, dialect, functionRegistry); String template = Template.renderWhereStringTemplate(formula, dialect, functionRegistry);
return StringHelper.replace( template, "{alias}", Template.TEMPLATE ); return safeInterning( StringHelper.replace( template, "{alias}", Template.TEMPLATE ) );
} }
@Override @Override