OPENJPA-589 Can not retrieve M-to-M data when DataCache is on

committing patch provided by Fay Wang

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@654658 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Catalina Wei 2008-05-09 00:13:48 +00:00
parent df0902d4cf
commit 3187089432
1 changed files with 11 additions and 7 deletions

View File

@ -87,16 +87,20 @@ public abstract class AbstractPCData
Map m = (Map) data;
Map m2 = (Map) sm.newFieldProxy(fmd.getIndex());
Collection keys = new ArrayList (m.size());
Collection values = new ArrayList(m.size());
for (Iterator mi = m.entrySet().iterator(); mi.hasNext();)
keys.add(mi.next());
for (Iterator<Map.Entry> mi = m.entrySet().iterator();
mi.hasNext();) {
Map.Entry e = mi.next();
keys.add(e.getKey());
values.add(e.getValue());
}
Object[] keyArray = keys.toArray();
Object[] values = toNestedFields(sm, fmd.getElement(),
keys, fetch, context).toArray();
int idx = 0;
for (Iterator mi = m.entrySet().iterator(); mi.hasNext(); idx++)
m2.put(keyArray[idx], values[idx]);
Object[] valueArray = toNestedFields(sm, fmd.getElement(),
values, fetch, context).toArray();
for (int idx = 0; idx < keyArray.length; idx++)
m2.put(keyArray[idx], valueArray[idx]);
return m2;
case JavaTypes.ARRAY: