Hibernate SQLQuery#executeUpdate() does not regard SQLQuery#setTimeout() and does not invoke Statement#setQueryTimeout()

Solution Unverified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x
    • 7.x
  • Hibernate

Issue

  • Hibernate SQLQuery#executeUpdate() does not regard SQLQuery#setTimeout() and does not invoke Statement#setQueryTimeout().
  • As far as I tested, Statement#setQueryTimeout() is invoked when executingSQLQuery.list() and Query.executeUpdate() works fine but it's not invoked when executing SQLQuery.executeUpdate().

Resolution

This is a bug. The following BZ and JIRAs are created for this issue. This will be fixed in EAP 7.1.1 or later:

Root Cause

  • org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate() does not use the timeout value set by SQLQuery#setTimeout() and does not call Statement.setQueryTimeout(). That's why SQLQuery#executeUpdate() ignores SQLQuery#setTimeout() and does not invoke Statement#setQueryTimeout().
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.