openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1700884 - in /openjpa/branches/2.2.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-project/src/doc/manual/
Date Wed, 02 Sep 2015 20:04:18 GMT
Author: hthomann
Date: Wed Sep  2 20:04:18 2015
New Revision: 1700884

URL: http://svn.apache.org/r1700884
Log:
OPENJPA-2517: Option to allow the javax.persistence.query.timeout property to apply to EntityManager
operations.

Modified:
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
    openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java?rev=1700884&r1=1700883&r2=1700884&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
Wed Sep  2 20:04:18 2015
@@ -206,8 +206,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/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java?rev=1700884&r1=1700883&r2=1700884&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionary.java
Wed Sep  2 20:04:18 2015
@@ -238,6 +238,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/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml?rev=1700884&r1=1700883&r2=1700884&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml (original)
+++ openjpa/branches/2.2.x/openjpa-project/src/doc/manual/ref_guide_dbsetup.xml Wed Sep  2
20:04:18 2015
@@ -2998,6 +2998,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