Bug 1508697 - Hibernate SQLQuery#executeUpdate() does not invoke Statement#setQueryTimeout()
Summary: Hibernate SQLQuery#executeUpdate() does not invoke Statement#setQueryTimeout()
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.4.17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Gail Badner
QA Contact: Pavel Slavicek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-11-02 00:58 UTC by Masafumi Miura
Modified: 2021-03-11 16:10 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-19 12:44:14 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
hibernate-reproducer.zip (73.93 KB, application/zip)
2017-11-02 00:58 UTC, Masafumi Miura
no flags Details
a proposed patch for NativeSQLQueryPlan (1.55 KB, patch)
2017-11-02 01:00 UTC, Masafumi Miura
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3232101 0 None None None 2017-11-06 07:07:42 UTC

Description Masafumi Miura 2017-11-02 00:58:28 UTC
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().

Comment 1 Masafumi Miura 2017-11-02 01:00:41 UTC
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.

Comment 2 Masafumi Miura 2017-11-02 08:30:22 UTC
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


Note You need to log in before you can comment on or make changes to this bug.