openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1700885 - in /openjpa/trunk: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
Date Wed, 02 Sep 2015 20:06:42 GMT
Author: hthomann
Date: Wed Sep  2 20:06:41 2015
New Revision: 1700885

URL: http://svn.apache.org/r1700885
Log:
OPENJPA-2517: Option to allow the javax.persistence.query.timeout property to apply to EntityManager
operations.  Ported 2.2.x changes to trunk.

Modified:
    openjpa/trunk/   (props changed)
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml

Propchange: openjpa/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep  2 20:06:41 2015
@@ -2,5 +2,5 @@
 /openjpa/branches/2.0.x:1504611
 /openjpa/branches/2.1.x:1415379,1415398,1485010,1513249,1517838,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1636464,1655218,1662610,1673300,1673491,1686894
 /openjpa/branches/2.2.1.x:1415367,1415413,1415425,1504719,1508186,1530347,1533222,1539193,1651808,1686910
-/openjpa/branches/2.2.x:1384400,1415459-1415460,1415469,1485013,1530364,1533223,1580898,1580939,1591681,1631786,1641906,1642555,1666312,1686911
+/openjpa/branches/2.2.x:1384400,1415459-1415460,1415469,1485013,1530364,1533223,1580898,1580939,1591681,1631786,1641906,1642555,1666312,1686911,1700884
 /openjpa/branches/2.3.x:1533462,1535560,1536912,1540277,1564121

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java?rev=1700885&r1=1700884&r2=1700885&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
Wed Sep  2 20:06:41 2015
@@ -205,8 +205,26 @@ public class DataSourceFactory {
             ConfiguringConnectionDecorator ccd =
                 new ConfiguringConnectionDecorator();
             ccd.setTransactionIsolation(conf.getTransactionIsolationConstant());
-            ccd.setQueryTimeout(conf.getQueryTimeout() == -1 
-                ? -1 : conf.getQueryTimeout());
+            
+            //OPENJPA-2517: Allow a javax.persistence.query.timeout to apply to all
+            //EM operations (not just Query operations).  Convert from milliseconds
+            //to seconds.  See DBDictionary.setQueryTimeout for similar conversions.  
+            //DBDictionary.setQueryTimeout will log warnings for invalid values, 
+            //therefore there is no need to do so again here.  Furthermore, there is no 

+            //need to check for -1 here, ConfigurationConnectionDecorator checks for it.
+            int timeout = conf.getQueryTimeout();
+            if (dict.allowQueryTimeoutOnFindUpdate){
+                if (timeout > 0 && timeout < 1000) {
+                    // round up to 1 sec
+                    timeout = 1; 
+                }
+                else if (timeout >= 1000){
+                    timeout = timeout/1000;
+                }
+            }
+            
+            ccd.setQueryTimeout(timeout);
+            
             Log log = conf.getLog(JDBCConfiguration.LOG_JDBC);
             if (factory2 || !conf.isConnectionFactoryModeManaged()) {
                 if (!dict.supportsMultipleNontransactionalResultSets)

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1700885&r1=1700884&r2=1700885&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Sep  2 20:06:41 2015
@@ -241,6 +241,7 @@ public class DBDictionary
     public boolean supportsLockingWithInnerJoin = true;
     public boolean supportsLockingWithSelectRange = true;
     public boolean supportsQueryTimeout = true;
+    public boolean allowQueryTimeoutOnFindUpdate = false; //OPENJPA-2517
     public boolean simulateLocking = false;
     public boolean supportsSubselect = true;
     public boolean supportsCorrelatedSubselect = true;

Modified: openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml?rev=1700885&r1=1700884&r2=1700885&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml Wed Sep  2 20:06:41
2015
@@ -3045,6 +3045,27 @@ action on foreign keys.  Defaults to <li
 calls to <methodname> java.sql.Statement.setQueryTimeout</methodname>.
                     </para>
                 </listitem>
+                <listitem id="DBDictionary.AllowQueryTimeoutOnFindUpdate">
+                    <para>
+                    <indexterm>
+                        <primary>
+                            JDBC
+                        </primary>
+                        <secondary>
+                            QueryTimeout
+                        </secondary>
+                        <tertiary>
+                            AllowQueryTimeoutOnFindUpdate
+                        </tertiary>
+                    </indexterm>
+<literal>AllowQueryTimeoutOnFindUpdate</literal>: The JPA Specification defines
the 
+javax.persistence.query.timeout, in milliseconds, as a hint to the provider.  The hint
+is used for Query operations.  This property, when set to true, will allow the query timeout
hint
+to apply to EntityManager operations.  For example, when a 'find' is executed and the resultant
+entity updated, the query timeout will apply to the SQL update operation.  This property
defaults
+to false.</methodname>.
+                    </para>
+                </listitem>
                 <listitem id="DBDictionary.SupportsRestrictDeleteAction">
                     <para>
                     <indexterm>



Mime
View raw message