Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate logging in console with WARN HHH000174

Tags:

hibernate

jpa

I have a system with Hibernate 4.1.7 and Spring 1.3.4 jpa. When I run myEntity.findOne(id), the hibernate WARN logging in console:

[main]; WARN; org.hibernate.dialect.function.TemplateRenderer; - HHH000174: Function template anticipated four arguments, but arguments first encountered.

Find out about some possible solutions in but could not solve my problem in http://jira.xwiki.org/browse/XWIKI-9215, https://hibernate.atlassian.net/browse/HHH-6280.

I am checking the code logging in org.hibernate.dialect.function.TemplateRenderer

@SuppressWarnings({ "UnusedDeclaration" })
    public String render(List args, SessionFactoryImplementor factory) {
        int numberOfArguments = args.size();
        if ( getAnticipatedNumberOfArguments() > 0 && numberOfArguments != getAnticipatedNumberOfArguments() ) {
            LOG.missingArguments( getAnticipatedNumberOfArguments(), numberOfArguments );
        }
        StringBuilder buf = new StringBuilder();
        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();
    }
like image 508
diegohsi Avatar asked Sep 05 '14 14:09

diegohsi


2 Answers

First of all good research

Yes, this was raised as a bug earlier with Hibernate, and was provided with a fix also. But due to lack of test cases, it was rejected and never released as a part of subsequent releases.

The bug was introduced as a part of Hibernate 3.6.

So still needs to wait for somebody to raise the ticket, and provide suitable test cases and fix.

refer here for more details.

like image 77
Ankur Singhal Avatar answered Oct 22 '22 01:10

Ankur Singhal


The referenced (root cause) hibernate bug HHH-5676 was rejected so I expect no improvement in the near future with this WARNING.

There is a way to switch it off at least if it annoys you. You can restrict the logging level of the hibernate class TemplateRenderer to ERROR. The class TemplateRenderer does this log and (at this time) this is the only logging in that class. It depends on your logger how to do it. In my case:

logger.org.hibernate.dialect.function.TemplateRenderer.level=ERROR

Hiding this is risky because of obvious reasons. Do it carefully!

like image 45
Laszlo Hirdi Avatar answered Oct 22 '22 02:10

Laszlo Hirdi