Why is the query “SHOW WARNINGS” issued here? (Jpa / hibernate / mysql)

We are refactoring the persistence level of a Java application from a JDBC template to JPA / Hibernate.

I profile the SQL statements issued to the database, and I see that "SHOW WARNINGS" is issued many, many times. According to JProfiler, "SHOW WARNINGS" makes up a significant portion of "integral time."

What can cause a frequent SHOW WARNINGS warning?

This SHOW WARNINGS was not previously released using the Jdbc template.

Below is the portion of our stack related to persistence. The only change here is the introduction of JPA / Hibernate.

  • JPA / Hibernate: 4.3.6
  • MySQL driver: 5.1.33
  • MySQL Database: 5.6.20
  • JDBC Connection Pool: HikariCP-2.3.2

EDIT: This gives an approximate stack trace when SHOW WARNINGS appears.

com.mysql.jdbc.StatementImpl.getWarnings() com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy.getWarnings() org.hibernate.jpa.internal.QueryImpl.getSingleResult() com.mysema.query.jpa.impl.AbstractJPAQuery.getSingleResult(javax.persistence.Query) com.mysema.query.jpa.impl.AbstractJPAQuery.uniqueResult() com.mysema.query.jpa.impl.AbstractJPAQuery.uniqueResult(com.mysema.query.types.Expression) org.springframework.aop.framework.JdkDynamicAopProxy.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[ ]) com.sun.proxy.$Proxy115.findOne(com.mysema.query.types.Predicate) 
+5
source share
1 answer

This WHY message shows warnings: org.hibernate.engine.jdbc.spi.SqlExceptionHelper.handleAndClearWarnings() calls com.mysql.jdbc.StatementImpl.getWarnings() .

A comment in the Hibernate source code says:

"See HHH-9174. The statement # getWarnings can be an expensive call for many JDBC libraries. Do not do this if the log level does not allow a warning to register."

I upgraded the logging level from logback.xml to "org.hibernate" to ERROR. Profiling indicates that the SHOW WARNINGS request is NOT FULL.

This led to a slight performance improvement.

I would appreciate any data on whether it is really a good idea to disable SHOW WARNINGS here.

+8
source

All Articles