Created attachment 1346823 [details] hibernate-reproducer.zip ### Description of problem: Hibernate org.hibernate.SQLQuery#executeUpdate() does not invoke java.sql.Statement#setQueryTimeout() even if SQLQuery#setTimeout() is specified. Note that org.hibernate.SQLQuery#list() and org.hibernate.Query#executeUpdate() works fine but org.hibernate.SQLQuery#executeUpdate() does not work. ### Version-Release number of selected component (if applicable): EAP 6.4 CP17 (Hibernate 4.2.27.Final) ### How reproducible: Anytime ### Steps to Reproduce: 1. Enable spy log: /subsystem=logging/logger=jboss.jdbc.spy:add /subsystem=logging/logger=jboss.jdbc.spy:write-attribute(name="level", value="TRACE") 2. Build and deploy the attached reproducer, which is based on EAP 6 quickstarts hibernate4. mvn clean package jboss-as:deploy 3. Access the web-app 1) test.SelectServlet, which specifies SQLQuery.setTimeout(5) then execute SQLQuery.list(): curl http://localhost:8080/jboss-hibernate4/SelectServlet 2) test.UpdateServlet, which specifies SQLQuery.setTimeout(5) and execute SQLQuery.executeUpdate(): curl http://localhost:8080/jboss-hibernate4/UpdateServlet 3) test.UpdateServlet2, which specifies Query.setTimeout(5) and execute Query.executeUpdate(): curl http://localhost:8080/jboss-hibernate4/UpdateServlet2 ### Actual results: spy logging shows that Statement#setQueryTimeout() is not invoked in UpdateServlet although it's invoked in SelectServlet and UpdateServlet2. (You can confirm it with the spy log message "[Statement] setQueryTimeout(xxx)"). For example: 1) spy log for test.SelectServlet INFO [stdout] (http-/127.0.0.1:8080-1) start SelectServlet DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [DataSource] getConnection() DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [Connection] prepareStatement(select * from MemberHibernate4Demo) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [Statement] setQueryTimeout(5) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [PreparedStatement] executeQuery() ...(snip)... INFO [stdout] (http-/127.0.0.1:8080-1) end SelectServlet 2) spy log for test.UpdateServlet INFO [stdout] (http-/127.0.0.1:8080-1) start UpdateServlet DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [DataSource] getConnection() DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [Connection] prepareStatement(update MemberHibernate4Demo set name=? where id=0) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [PreparedStatement] setString(1, redhat) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [PreparedStatement] executeUpdate() ...(snip)... INFO [stdout] (http-/127.0.0.1:8080-1) end UpdateServlet 3) spy log for test.UpdateServlet2 INFO [stdout] (http-/127.0.0.1:8080-1) start UpdateServlet2 DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [DataSource] getConnection() DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [Connection] prepareStatement(update MemberHibernate4Demo set name=? where id=0) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [PreparedStatement] setString(1, redhat2) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [Statement] setQueryTimeout(5) DEBUG [jboss.jdbc.spy] (http-/127.0.0.1:8080-1) java:jboss/datasources/Hibernate4QuickstartDS [PreparedStatement] executeUpdate() ...(snip)... INFO [stdout] (http-/127.0.0.1:8080-1) end UpdateServlet2 ### Expected results: Statement#setQueryTimeout() should also be invoked for SQLQuery#executeUpdate() in test.UpdateServlet. ### Additional info: It looks org.hibernate.engine.query.spi.NativeSQLQueryPlan#performExecuteUpdate() misses calling "Statement#setQueryTimeout().
Created attachment 1346824 [details] a proposed patch for NativeSQLQueryPlan It looks org.hibernate.engine.query.spi.NativeSQLQueryPlan#performExecuteUpdate() misses calling "Statement#setQueryTimeout(). I attached a possible proposed patch for this.
Same issue exists in EAP 7.x, so the following JBEAP JIRAs are opened: - 7.1.z: https://issues.jboss.org/browse/JBEAP-13683 - 7.0.z: https://issues.jboss.org/browse/JBEAP-13684 Also Hibernate JIRA is opened: - https://hibernate.atlassian.net/browse/HHH-12075