openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fayw...@apache.org
Subject svn commit: r930916 - /openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
Date Mon, 05 Apr 2010 17:46:02 GMT
Author: faywang
Date: Mon Apr  5 17:46:02 2010
New Revision: 930916

URL: http://svn.apache.org/viewvc?rev=930916&view=rev
Log:
OPENJPA-1608: port the fix to openjpa 2.0.x

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

Modified: openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java?rev=930916&r1=930915&r2=930916&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
(original)
+++ openjpa/branches/2.0.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/InformixDictionary.java
Mon Apr  5 17:46:02 2010
@@ -27,7 +27,6 @@ import java.sql.Statement;
 import java.sql.Types;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Set;
 
 import org.apache.openjpa.jdbc.identifier.DBIdentifier;
 import org.apache.openjpa.jdbc.identifier.DBIdentifier.DBIdentifierType;
@@ -317,24 +316,15 @@ public class InformixDictionary
 
         // if we haven't already done so, initialize the lock mode of the
         // connection
-        if (lockModeEnabled && _seenConnections.add(conn)) {
-            String sql = "SET LOCK MODE TO WAIT";
-            if (lockWaitSeconds > 0)
-                sql = sql + " " + lockWaitSeconds;
-
-            Statement stmnt = null;
-            try {
-                stmnt = conn.createStatement();
-                stmnt.executeUpdate(sql);
-            } catch (SQLException se) {
-                throw SQLExceptions.getStore(se, this);
-            } finally {
-                if (stmnt != null)
-                    try {
-                        stmnt.close();
-                    } catch (SQLException se) {
-                    }
+        if (_seenConnections.add(conn)) {
+            if (lockModeEnabled) {
+                String sql = "SET LOCK MODE TO WAIT";
+                if (lockWaitSeconds > 0)
+                    sql = sql + " " + lockWaitSeconds;
+                execute(sql, conn);
             }
+            String sql = "SET ENVIRONMENT RETAINUPDATELOCKS 'ALL'";
+            execute(sql, conn);
         }
 
         // the datadirect driver requires that we issue a rollback before using
@@ -346,6 +336,22 @@ public class InformixDictionary
             }
         return conn;
     }
+    
+    private void execute(String sql, Connection conn) {
+        Statement stmnt = null;
+        try {
+            stmnt = conn.createStatement();
+            stmnt.executeUpdate(sql);
+        } catch (SQLException se) {
+            throw SQLExceptions.getStore(se, this);
+        } finally {
+            if (stmnt != null)
+                try {
+                    stmnt.close();
+                } catch (SQLException se) {
+                }
+        }
+    }
 
     @Override
     public void indexOf(SQLBuffer buf, FilterValue str, FilterValue find,



Mime
View raw message