Vector primaryKeyValues = new Vector();
primaryKeyValues.setSize(pkFieldNames.size());
HashMap primaryKeyMap = new HashMap();
// for each source xmlField, get the value from the row and store
for (Iterator fieldIt = getFields().iterator(); fieldIt.hasNext();) {
XMLField fld = (XMLField) fieldIt.next();
XMLField tgtFld = (XMLField) getSourceToTargetKeyFieldAssociations().get(fld);
Object fieldValue = databaseRow.getValues(fld);
if ((fieldValue == null) || (fieldValue instanceof String) || !(fieldValue instanceof Vector)) {
return cp.containerInstance();
}
// fix for bug# 5687430
// need to get the actual type of the target (i.e. int, String, etc.)
// and use the converted value when checking the cache.
XMLConversionManager xmlConversionManager = (XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager();
Vector newValues = new Vector();
for (Iterator valIt = ((Vector) fieldValue).iterator(); valIt.hasNext();) {
for (StringTokenizer stok = new StringTokenizer((String) valIt.next()); stok.hasMoreTokens();) {
Object value = xmlConversionManager.convertObject(stok.nextToken(), descriptor.getTypedField(tgtFld).getType());
if (value != null) {
newValues.add(value);
}
}
}
primaryKeyMap.put(tgtFld.getXPath(), newValues);
}
// store the Reference instance on the resolver for use during mapping resolution phase
ReferenceResolver resolver = ReferenceResolver.getInstance(sourceQuery.getSession());
if (resolver != null) {
resolver.addReference(new Reference(this, targetObject, referenceClass, primaryKeyMap));