From 75bd5fe6a7a6101c5f925ca5f7a05e07ae8c1fe6 Mon Sep 17 00:00:00 2001 From: Donald Woods Date: Tue, 22 Jun 2010 13:31:01 +0000 Subject: [PATCH] OPENJPA-1700 FindBugs - Inefficient use of keySet iterator instead of entrySet iterator. Also, inefficient use of temporary Map when results can be used immediately git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@956883 13f79535-47bb-0310-9956-ffa450edef68 --- .../openjpa/jdbc/kernel/MixedLockManager.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java index 429419b01..75131156d 100644 --- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java +++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/MixedLockManager.java @@ -88,22 +88,17 @@ public class MixedLockManager extends PessimisticLockManager { // if(!dict.supportsLockingWithMultipleTables) { // look for columns mapped to secondary tables which need to be locked - Map colsMappedToSecTable = new HashMap(); FieldMapping fms[] = mapping.getFieldMappings(); for( FieldMapping fm : fms) { DBIdentifier secTableName = fm.getMappingInfo().getTableIdentifier(); - if(!DBIdentifier.isNull(secTableName)) { - colsMappedToSecTable.put(secTableName, fm); + if (!DBIdentifier.isNull(secTableName)) { + // select only the PK columns, since we just want to lock + Select select = factory.newSelect(); + select.select(fm.getColumns()); + select.whereForeignKey(fm.getJoinForeignKey(), id, mapping, _store); + sqls.add(select.toSelect(true, fetch)); } } - for( DBIdentifier secTableName : colsMappedToSecTable.keySet()) { - FieldMapping fm = colsMappedToSecTable.get(secTableName); - // select only the PK columns, since we just want to lock - Select select = factory.newSelect(); - select.select(fm.getColumns()); - select.whereForeignKey(fm.getJoinForeignKey(), id, mapping, _store); - sqls.add(select.toSelect(true, fetch)); - } } return sqls; }