[ 
https://issues.apache.org/jira/browse/OPENJPA-2517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15204390#comment-15204390
 ] 

Heath Thomann commented on OPENJPA-2517:
----------------------------------------

HI!  I've recently taken another look at this issue.  I wanted to try to 
summarize all the comments made so far, and add some clarification.  Basically, 
there are three issues with OpenJPA's handling of  
javax.persistence.query.timeout (QT for short):

1) OpenJPA applies the QT to all EM operations (e.g find/update).
2) OpenJPA uses seconds as the QT rather than milliseconds in #1.
3) OpenJPA doesn't round up QT values less than 1000.

It is explained in previous comments that, as per the JPA Spec, the QT should 
only apply to Query operations (methods on the Query interface).  Let me be 
clear and state that OpenJPA does properly apply the QT to Query operations.  
There are no issues for Query operations.  The issues here are with the QT 
being applied to EM operations (#1).  Given the fact that the QT is applied to 
EM operations when it shouldn't, #2 and #3 are moot.  However, since it was 
decided not to remove the QT from EM operations because of the risk of 
regression, #2 and #3 are not consistent with the way the QT is handled for 
Query operations.  For Query operations, OpenJPA rounds the QT to 1000 if the 
user sets the QT to a value less than 1000.  Furthermore, for Query operations 
OpenJPA converts the milliseconds to seconds and passes that value to the JDBC 
driver since the driver expects units of seconds.  

The purpose of the fix provider in this JIRA, and the property 
openjpa.jdbc.DBDictionary.allowQueryTimeoutOnFindUpdate, was to continue to 
allow #1, but resolve #2 and #3.  In other words, we did not want to run the 
risk of regressing users by change #1 such that the QT no longer applies to all 
EM operations.  At a later date, and another JIRA, we could investigate a 
change to provide a property to fix #1 by restricting the QT to only Query 
operations.  The fix of this JIRA however fixes #2 and #3 in order to maintain 
a consistent story between EM operations and Query operations.  In other words, 
when property openjpa.jdbc.DBDictionary.allowQueryTimeoutOnFindUpdate is set to 
true, the QT will be converted to milliseconds, and any value less than 1000 
will be rounded up to 1000. 

Finally, I would like to note that a user can set the QT to 0 to entirely 
disable the setting of a timeout.  This would disabled the QT for both Query 
and EM operations.

Thanks,

Heath

> Incorrect the time unit of query timeout value.
> -----------------------------------------------
>
>                 Key: OPENJPA-2517
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2517
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 2.2.0, 2.2.1, 2.2.2, 2.3.0
>            Reporter: Masafumi Koba
>            Assignee: Heath Thomann
>             Fix For: 2.2.3, 2.4.1
>
>         Attachments: OPENJPA-2517-2.2.x.patch, OPENJPA-2517.patch, 
> openjpa-querytimeout-bug.zip, openjpa-querytimeout-working.zip
>
>
> The value of the "javax.persistence.query.timeout" property have been passed 
> to the java.sql.Statement.setQueryTimeout(int) in milliseconds rather than 
> seconds.
> The query timeout milliseconds should be converted to seconds.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to