diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index 5a3a66d274..e31728cec8 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -2418,7 +2418,9 @@ public class Configuration implements Serializable { } public void addSqlFunction(String functionName, SQLFunction function) { - sqlFunctions.put( functionName, function ); + // HHH-7721: SQLFunctionRegistry expects all lowercase. Enforce, + // just in case a user's customer dialect uses mixed cases. + sqlFunctions.put( functionName.toLowerCase(), function ); } public TypeResolver getTypeResolver() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index bc7835d061..87793bcce1 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -598,7 +598,9 @@ public abstract class Dialect implements ConversionContext { // function support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ protected void registerFunction(String name, SQLFunction function) { - sqlFunctions.put( name, function ); + // HHH-7721: SQLFunctionRegistry expects all lowercase. Enforce, + // just in case a user's customer dialect uses mixed cases. + sqlFunctions.put( name.toLowerCase(), function ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java b/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java index e013421538..9eec303f82 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/function/SQLFunctionRegistry.java @@ -38,7 +38,6 @@ public class SQLFunctionRegistry { } public SQLFunction findSQLFunction(String functionName) { - // TODO: lower casing done here. Was done "at random" before; maybe not needed at all ? String name = functionName.toLowerCase(); SQLFunction userFunction = userFunctions.get( name ); return userFunction != null @@ -47,7 +46,6 @@ public class SQLFunctionRegistry { } public boolean hasFunction(String functionName) { - // TODO: toLowerCase was not done before. Only used in Template. String name = functionName.toLowerCase(); return userFunctions.containsKey( name ) || dialect.getFunctions().containsKey( name ); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java index 6b56e102bb..22c57349b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SessionFactoryHelper.java @@ -361,7 +361,7 @@ public class SessionFactoryHelper { * @return The sql function, or null if not found. */ public SQLFunction findSQLFunction(String functionName) { - return sfi.getSqlFunctionRegistry().findSQLFunction( functionName.toLowerCase() ); + return sfi.getSqlFunctionRegistry().findSQLFunction( functionName ); } /**