openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r956939 - in /openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc: kernel/PreparedQueryImpl.java kernel/PreparedSQLStoreQuery.java meta/VersionMappingInfo.java
Date Tue, 22 Jun 2010 16:13:27 GMT
Author: dwoods
Date: Tue Jun 22 16:13:27 2010
New Revision: 956939

URL: http://svn.apache.org/viewvc?rev=956939&view=rev
Log:
OPENJPA-1700 FindBugs - Inefficient use of keySet iterator instead of entrySet iterator

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionMappingInfo.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java?rev=956939&r1=956938&r2=956939&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedQueryImpl.java
Tue Jun 22 16:13:27 2010
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.FieldMapping;
@@ -318,11 +319,13 @@ public class PreparedQueryImpl implement
         }
         Map<Integer, Object> result = new HashMap<Integer, Object>(_template);
         
-        for (Object key : user.keySet()) {
+        Set<Map.Entry<Object,Object>> userSet = user.entrySet();
+        for (Map.Entry<Object,Object> userEntry : userSet) {
+            Object key = userEntry.getKey();
             int[] indices = _userParamPositions.get(key);
             if (indices == null || indices.length == 0)
                 throw new UserException(_loc.get("uparam-no-pos", key, this));
-            Object val = user.get(key);
+            Object val = userEntry.getValue();
             if (ImplHelper.isManageable(val)) {
                 setPersistenceCapableParameter(result, val, indices, broker);
             } else if (val instanceof Collection) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java?rev=956939&r1=956938&r2=956939&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PreparedSQLStoreQuery.java
Tue Jun 22 16:13:27 2010
@@ -23,6 +23,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.openjpa.jdbc.kernel.exps.ExpContext;
 import org.apache.openjpa.jdbc.kernel.exps.QueryExpressionsState;
@@ -153,9 +154,11 @@ public class PreparedSQLStoreQuery exten
          */
         public Object[] toParameterArray(StoreQuery q, Map userParams) {
             Object[] array = new Object[userParams.size()];
-            for (Object key : userParams.keySet()) {
-                int idx = ((Integer)key).intValue();
-                array[idx] = userParams.get(key);
+
+            Set<Map.Entry<Object,Object>> userSet = userParams.entrySet();
+            for (Map.Entry<Object,Object> userEntry : userSet) {
+                int idx = ((Integer)userEntry.getKey()).intValue();
+                array[idx] = userEntry.getValue();
             }
             return array;
         }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionMappingInfo.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionMappingInfo.java?rev=956939&r1=956938&r2=956939&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionMappingInfo.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/VersionMappingInfo.java
Tue Jun 22 16:13:27 2010
@@ -91,10 +91,13 @@ public class VersionMappingInfo
     	}
     	MappingDefaults def = vers.getMappingRepository().getMappingDefaults();
     	List<Column> result = new ArrayList<Column>();
-    	for (Table table : assign.keySet()) {
-    		List<Column> cols = assign.get(table);
-    		Column[] partTemplates = cols.toArray(new Column[cols.size()]);
-    		def.populateColumns(vers, table, partTemplates);
+
+        Set<Map.Entry<Table,List<Column>>> assignSet = assign.entrySet();
+        for (Map.Entry<Table,List<Column>> assignEntry : assignSet) {
+            Table table = assignEntry.getKey();
+            List<Column> cols = assignEntry.getValue();
+            Column[] partTemplates = cols.toArray(new Column[cols.size()]);
+            def.populateColumns(vers, table, partTemplates);
             result.addAll(Arrays.asList(createColumns(vers, null, partTemplates,
     				table, adapt)));
     	}



Mime
View raw message