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

(cherry picked from commit 096b436f3d)
This commit is contained in:
Sanne Grinovero 2018-08-17 12:41:08 +01:00 committed by Gail Badner
parent e520fd9b99
commit 5f7b41d54b
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.sql.Template;
import static org.hibernate.internal.util.StringHelper.safeInterning;
/**
* A column of a relational database table
*
@ -268,10 +270,12 @@ public class Column implements Selectable, Serializable, Cloneable {
@Override
public String getTemplate(Dialect dialect, SQLFunctionRegistry functionRegistry) {
return hasCustomRead()
return safeInterning(
hasCustomRead()
// see note in renderTransformerReadFragment wrt access to SessionFactory
? Template.renderTransformerReadFragment( customRead, getQuotedName( dialect ) )
: Template.TEMPLATE + '.' + getQuotedName( dialect );
: Template.TEMPLATE + '.' + getQuotedName( dialect )
);
}
public boolean hasCustomRead() {

View File

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