OPENJPA-590 committing patch provided by Fay Wang

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@653595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2008-05-05 20:52:29 +00:00
parent 40fec0073e
commit efcc2577a6
2 changed files with 7 additions and 5 deletions

View File

@ -21,6 +21,7 @@ package org.apache.openjpa.kernel.exps;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections.map.LinkedMap; import org.apache.commons.collections.map.LinkedMap;
@ -47,7 +48,7 @@ public class QueryExpressions
/** /**
* Map of {@link FieldMetaData},{@link Value} for update statements. * Map of {@link FieldMetaData},{@link Value} for update statements.
*/ */
public Map updates = Collections.EMPTY_MAP; public Map<Path, Value> updates = Collections.EMPTY_MAP;
public int distinct = DISTINCT_AUTO; public int distinct = DISTINCT_AUTO;
public String alias = null; public String alias = null;
public Value[] projections = EMPTY_VALUES; public Value[] projections = EMPTY_VALUES;
@ -86,7 +87,7 @@ public class QueryExpressions
*/ */
public void putUpdate(Path path, Value val) { public void putUpdate(Path path, Value val) {
if (updates == Collections.EMPTY_MAP) if (updates == Collections.EMPTY_MAP)
updates = new HashMap(); updates = new LinkedHashMap<Path, Value>();
updates.put(path, val); updates.put(path, val);
} }

View File

@ -26,6 +26,7 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import java.util.Stack; import java.util.Stack;
import java.util.TreeSet; import java.util.TreeSet;
@ -1569,12 +1570,12 @@ public class JPQLExpressionBuilder
} }
JPQLNode[] findChildrenByID(int id) { JPQLNode[] findChildrenByID(int id) {
Collection set = new HashSet(); Collection<JPQLNode> set = new LinkedHashSet<JPQLNode>();
findChildrenByID(id, set); findChildrenByID(id, set);
return (JPQLNode[]) set.toArray(new JPQLNode[set.size()]); return set.toArray(new JPQLNode[set.size()]);
} }
private void findChildrenByID(int id, Collection set) { private void findChildrenByID(int id, Collection<JPQLNode> set) {
for (int i = 0; children != null && i < children.length; i++) { for (int i = 0; children != null && i < children.length; i++) {
if (children[i].id == id) if (children[i].id == id)
set.add(children[i]); set.add(children[i]);