Issue Type: Bug Bug
Affects Versions: 3.6.9
Assignee: Unassigned
Components: core
Created: 10/Jun/13 5:31 AM
Description:

This pages describes the usage of the trim() function: http://thecafetechno.com/tutorials/hibernate/hql-concat-trim-function-example/

We're using it like this:

SELECT field.value  FROM BaseObject as obj, StringProperty as field WHERE obj.name=:groupdocname and obj.className=:groupclassname and obj.id=field.id.id and (trim(both from field.value)<>'' or (trim(both from field.value) is not null and '' is null))

Thus we use the trim with 3 arguments (since we don't want to specify the character to trim, we want to use the default whitespace char).

However in Dialect.java, the trim() function is registered with 4 arguments only:

registerFunction( "trim", new SQLFunctionTemplate( StandardBasicTypes.STRING, "trim(?1 ?2 ?3 ?4)" ) );

Thus in TemplateRenderer:java it prints the warning:

	public String render(List args, SessionFactoryImplementor factory) {
		int numberOfArguments = args.size();
		if ( getAnticipatedNumberOfArguments() > 0 && numberOfArguments != getAnticipatedNumberOfArguments() ) {
			log.warn( "Function template anticipated {} arguments, but {} arguments encountered",
					getAnticipatedNumberOfArguments(), numberOfArguments );
		}
		StringBuffer buf = new StringBuffer();
		for ( int i = 0; i < chunks.length; ++i ) {
			if ( i < paramIndexes.length ) {
				final int index = paramIndexes[i] - 1;
				final Object arg =  index < numberOfArguments ? args.get( index ) : null;
				if ( arg != null ) {
					buf.append( chunks[i] ).append( arg );
				}
			}
			else {
				buf.append( chunks[i] );
			}
		}
		return buf.toString();
	}

It should be allowed to use the trim() function with only 3 arguments without any warning.

Project: Hibernate ORM
Priority: Minor Minor
Reporter: Vincent Massol
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira