Vojtěch
Vojtěch

Reputation: 12436

Hibernate and Com_show_warnings == Com_select in MySQL

When looking into SHOW GLOBAL STATUS on my MySQL it is showing that Com_select and Com_show_warnings are more or less equal. That means that Hibernate executes SHOW WARNINGS for each query it executes. Is there a way to disable this? Google did not help :/

Upvotes: 3

Views: 328

Answers (1)

xsalefter
xsalefter

Reputation: 640

As explained in this blog post, hibernate force us to use SHOW WARNINGS when we set log level from warn or above.

This is the part of that code:

public void handleAndClearWarnings(
        Connection connection,
        WarningHandler handler) {
    try {
        /* This is the real method that causing the problem. */
        walkWarnings( connection.getWarnings(), handler );
    }
    catch (SQLException sqle) {
        // workaround for WebLogic
        LOG.debug( "could not log warnings", sqle );
    }
    try {
        // Sybase fail if we don't do that, sigh...
        connection.clearWarnings();
    }
    catch (SQLException sqle) {
        LOG.debug( "could not clear warnings", sqle );
    }
}

Thus, to avoid walkWarnings() method get executed, you could try to change log4j.logger.org.hibernate level to error.

Upvotes: 2

Related Questions