You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by jg...@apache.org on 2015/04/22 21:12:04 UTC

svn commit: r1675457 - /openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java

Author: jgrassel
Date: Wed Apr 22 19:12:03 2015
New Revision: 1675457

URL: http://svn.apache.org/r1675457
Log:
OPENJPA-2570: Allow an informix user the option to disable the RETAINUPDATELOCKS sql

Modified:
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java?rev=1675457&r1=1675456&r2=1675457&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java (original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java Wed Apr 22 19:12:03 2015
@@ -27,6 +27,7 @@ import java.sql.Statement;
 import java.sql.Types;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
 
@@ -82,8 +83,8 @@ public class InformixDictionary
 
     protected boolean useJCC = false;
     // weak set of connections we've already executed lock mode sql on
-    private final Collection _seenConnections = new ReferenceHashSet
-        (ReferenceHashSet.WEAK);
+    private final Collection _seenConnections = Collections.synchronizedSet(
+    		new ReferenceHashSet(ReferenceHashSet.WEAK));
 
     public boolean disableRetainUpdateLocksSQL=false;
 
@@ -324,21 +325,19 @@ public class InformixDictionary
 
         // if we haven't already done so, initialize the lock mode of the
         // connection
-        synchronized(_seenConnections) {
-            if (_seenConnections.add(conn)) {
-                if (lockModeEnabled) {
-                    String sql = "SET LOCK MODE TO WAIT";
-                    if (lockWaitSeconds > 0)
-                        sql = sql + " " + lockWaitSeconds;
-                    execute(sql, conn, true);
-                }
-                
-                if (!disableRetainUpdateLocksSQL){
-                    String sql = "SET ENVIRONMENT RETAINUPDATELOCKS 'ALL'";
-                    execute(sql, conn, false);
-                }
+        if (_seenConnections.add(conn)) {
+            if (lockModeEnabled) {
+                String sql = "SET LOCK MODE TO WAIT";
+                if (lockWaitSeconds > 0)
+                    sql = sql + " " + lockWaitSeconds;
+                execute(sql, conn, true);
             }
-        }       
+            
+            if (!disableRetainUpdateLocksSQL){
+                String sql = "SET ENVIRONMENT RETAINUPDATELOCKS 'ALL'";
+                execute(sql, conn, false);
+            }
+        }      
 
         // the datadirect driver requires that we issue a rollback before using
         // each connection