Hibernate and Com_show_warnings == Com_select in MySQL



在我的MySQL上查看SHOW GLOBAL STATUS时,会发现Com_selectCom_show_warnings或多或少相等。这意味着Hibernate为它执行的每个查询执行SHOW WARNINGS。有没有办法禁用它?谷歌没有帮助:/

如本文所述,当我们从warn或更高级别设置日志级别时,hibernate会强制我们使用SHOW WARNINGS

这是代码的一部分:

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 );
    }
}

因此,为了避免walkWarnings()方法被执行,您可以尝试将log4j.logger.org.hibernate级别更改为error

相关内容

最新更新