The ANSI SQL TRIM function is defined as:
However, the first three arguments to the function are optional. Therefore, all the following calls to this function are valid:
However, any time this function is called from HQL with less than the maximum allowed of 4 parameters, the following warning message is seen in the logs, generated from the class org.hibernate.dialect.function.TemplateRenderer:
For example, the following Spring Data JPA repository method (which generates an HQL query) leads to this error:
This warning message has no impact on the actual execution of the code, which works as expected. However, WARN log level seems excessive for this case. The following portion of the code generates the warning:
At the very least, the severity level for this message should be changed to INFO. A proper check should know the minimum and maximum number of mandatory arguments allowed for the SQL function and compare the supplied number of arguments with this range. If the number of arguments is outside this range, the method must halt the operation by throwing an exception, instead of just logging a message and continuing.
Have attached a Maven project as a sample. Just run the test cases to see the aforementioned warning message being displayed.