Program: 64091
Project: 64091
Buggy source:
@SuppressWarnings("String_Node_Str") public static Object buildId(PersistenceContext app,String entityName,String idString){
  DatabaseSession session=app.getJpaSession();
  ClassDescriptor descriptor=app.getDescriptor(entityName);
  List<DatabaseMapping> pkMappings=descriptor.getObjectBuilder().getPrimaryKeyMappings();
  List<SortableKey> pkIndices=new ArrayList<SortableKey>();
  int index=0;
  int multitenantPKMappings=0;
  for (  DatabaseMapping mapping : pkMappings) {
    if (mapping.isMultitenantPrimaryKeyMapping()) {
      multitenantPKMappings++;
    }
 else {
      pkIndices.add(new SortableKey(mapping,index));
      index++;
    }
  }
  Collections.sort(pkIndices);
  Object[] keyElements=new Object[pkMappings.size() - multitenantPKMappings];
  StringTokenizer tokenizer=new StringTokenizer(idString,SEPARATOR_STRING);
  int tokens=tokenizer.countTokens();
  if (tokens + multitenantPKMappings != pkMappings.size()) {
    throw new RuntimeException("String_Node_Str");
  }
  index=0;
  Iterator<SortableKey> iterator=pkIndices.iterator();
  while (tokenizer.hasMoreTokens()) {
    SortableKey key=iterator.next();
    String token=tokenizer.nextToken();
    DatabaseMapping mapping=key.getMapping();
    Class attributeClasification=mapping.getAttributeClassification();
    if (attributeClasification == null) {
      if ((mapping.getFields() != null) && (!mapping.getFields().isEmpty())) {
        attributeClasification=mapping.getFields().get(0).getType();
      }
    }
    Object idValue=session.getPlatform().getConversionManager().convertObject(token,attributeClasification);
    keyElements[key.getIndex()]=idValue;
    index++;
  }
  if (descriptor.hasCMPPolicy()) {
    CMP3Policy policy=(CMP3Policy)descriptor.getCMPPolicy();
    return policy.createPrimaryKeyInstanceFromPrimaryKeyValues((AbstractSession)session,new int[]{0},keyElements);
  }
  if (keyElements.length == 1) {
    return keyElements[0];
  }
  return keyElements;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static Object buildId(PersistenceContext app,String entityName,String idString){
  DatabaseSession session=app.getJpaSession();
  ClassDescriptor descriptor=app.getDescriptor(entityName);
  List<DatabaseMapping> pkMappings=descriptor.getObjectBuilder().getPrimaryKeyMappings();
  List<SortableKey> pkIndices=new ArrayList<SortableKey>();
  int index=0;
  int multitenantPKMappings=0;
  for (  DatabaseMapping mapping : pkMappings) {
    if (mapping.isMultitenantPrimaryKeyMapping()) {
      multitenantPKMappings++;
    }
 else {
      pkIndices.add(new SortableKey(mapping,index));
      index++;
    }
  }
  Collections.sort(pkIndices);
  Object[] keyElements=new Object[pkMappings.size() - multitenantPKMappings];
  StringTokenizer tokenizer=new StringTokenizer(idString,SEPARATOR_STRING);
  int tokens=tokenizer.countTokens();
  if (tokens + multitenantPKMappings != pkMappings.size()) {
    throw new RuntimeException("String_Node_Str");
  }
  index=0;
  Iterator<SortableKey> iterator=pkIndices.iterator();
  while (tokenizer.hasMoreTokens()) {
    SortableKey key=iterator.next();
    String token=tokenizer.nextToken();
    DatabaseMapping mapping=key.getMapping();
    Class attributeClasification=mapping.getAttributeClassification();
    if (attributeClasification == null) {
      if ((mapping.getFields() != null) && (!mapping.getFields().isEmpty())) {
        attributeClasification=mapping.getFields().get(0).getType();
      }
    }
    Object idValue=session.getDatasourcePlatform().getConversionManager().convertObject(token,attributeClasification);
    keyElements[key.getIndex()]=idValue;
    index++;
  }
  if (descriptor.hasCMPPolicy()) {
    CMP3Policy policy=(CMP3Policy)descriptor.getCMPPolicy();
    return policy.createPrimaryKeyInstanceFromPrimaryKeyValues((AbstractSession)session,new int[]{0},keyElements);
  }
  if (keyElements.length == 1) {
    return keyElements[0];
  }
  return keyElements;
}