/** * INTERNAL: Retrieve the target object's primary key value that is mapped to a given source xpath * (in the source-target key field association list). * * @param targetObject - the reference class instance that holds the required pk value * @param xmlFld * @param session * @return null if the target object is null, the reference class is null, or a primary key field * name does not exist on the reference descriptor that matches the target field name - * otherwise, return the associated primary key value */ public Object buildFieldValue(Object targetObject, XMLField xmlFld, AbstractSession session) { if (targetObject == null || getReferenceClass() == null) { return null; } ClassDescriptor descriptor = getReferenceDescriptor(); ObjectBuilder objectBuilder = descriptor.getObjectBuilder(); Vector pks = objectBuilder.extractPrimaryKeyFromObject(targetObject, session); XMLField tgtXMLField = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlFld); int idx = descriptor.getPrimaryKeyFields().indexOf(tgtXMLField); if (idx == -1) { return null; } return pks.get(idx); }