Hibernate SQLQuery#executeUpdate() does not regard SQLQuery#setTimeout() and does not invoke Statement#setQueryTimeout()
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- 7.x
- Hibernate
Issue
- Hibernate
SQLQuery#executeUpdate()does not regardSQLQuery#setTimeout()and does not invokeStatement#setQueryTimeout(). - As far as I tested,
Statement#setQueryTimeout()is invoked when executingSQLQuery.list()andQuery.executeUpdate()works fine but it's not invoked when executingSQLQuery.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:
- EAP 6.4.x: <This content is not included.https://bugzilla.redhat.com/show_bug.cgi?id=1508697>
- EAP 7.1.z: <Content from issues.jboss.org is not included.https://issues.jboss.org/browse/JBEAP-13683>
- EAP 7.2.0: <Content from issues.jboss.org is not included.https://issues.jboss.org/browse/JBEAP-14114>
- Hibernate (community upstream): <Content from hibernate.atlassian.net is not included.https://hibernate.atlassian.net/browse/HHH-12075>
Root Cause
org.hibernate.engine.query.spi.NativeSQLQueryPlan.performExecuteUpdate()does not use the timeout value set bySQLQuery#setTimeout()and does not callStatement.setQueryTimeout(). That's whySQLQuery#executeUpdate()ignoresSQLQuery#setTimeout()and does not invokeStatement#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.