Add hibernate.dialect.show_hql_functions

Very useful feature for logging available functions
This commit is contained in:
gavinking 2020-01-27 16:44:58 +01:00 committed by Steve Ebersole
parent 96c948b06b
commit f0d93200b5
2 changed files with 18 additions and 0 deletions

View File

@ -736,6 +736,13 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
*/
String USE_SQL_COMMENTS ="hibernate.use_sql_comments";
/**
* Enable logging of functions registered by the
* {@linkplain AvailableSettings#DIALECT configured}
* SQL {@link org.hibernate.dialect.Dialect}.
*/
String SHOW_HQL_FUNCTIONS = "hibernate.dialect.show_hql_functions";
/**
* Maximum depth of outer join fetching
*/

View File

@ -111,6 +111,17 @@ public class QueryEngine {
if ( userDefinedRegistry != null ) {
userDefinedRegistry.overlay( sqmFunctionRegistry );
}
final boolean showSQLFunctions = ConfigurationHelper.getBoolean(
AvailableSettings.SHOW_HQL_FUNCTIONS,
serviceRegistry.getService( ConfigurationService.class ).getSettings(),
false
);
if ( showSQLFunctions ) {
sqmFunctionRegistry.getFunctionsByName().forEach(
entry -> System.out.println( entry.getValue().getSignature( entry.getKey() ) )
);
}
}
/**