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
This commit is contained in:
Donald Woods 2010-06-22 13:31:01 +00:00
parent af772a734b
commit 75bd5fe6a7
1 changed files with 6 additions and 11 deletions

View File

@ -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<DBIdentifier,FieldMapping> colsMappedToSecTable = new HashMap<DBIdentifier,FieldMapping>();
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;
}