Program: 64612
Project: 64612
Buggy source:
/** 
 * build a shell of an object based on a primary key.  The object shell will be an instance of the object with only primary key populated
 * @param context
 * @param entityType
 * @param id
 * @return
 */
public static Object buildObjectShell(PersistenceContext context,String entityType,Object id){
  ClassDescriptor descriptor=context.getDescriptor(entityType);
  List<DatabaseMapping> pkMappings=descriptor.getObjectBuilder().getPrimaryKeyMappings();
  Object entity=null;
  if (descriptor.hasCMPPolicy()) {
    CMP3Policy policy=(CMP3Policy)descriptor.getCMPPolicy();
    entity=policy.createBeanUsingKey(id,context.getJpaSession());
  }
 else   if (entity instanceof DynamicEntity) {
    DynamicEntityImpl dynamicEntity=(DynamicEntityImpl)context.newEntity(entityType);
    if (pkMappings.size() == 1) {
      dynamicEntity.set(pkMappings.get(0).getAttributeName(),id);
    }
 else {
      List<SortableKey> pkIndices=new ArrayList<SortableKey>();
      int index=0;
      for (      DatabaseMapping mapping : pkMappings) {
        pkIndices.add(new SortableKey(mapping,index));
        index++;
      }
      Collections.sort(pkIndices);
      Object[] keyElements=(Object[])id;
      for (      SortableKey key : pkIndices) {
        dynamicEntity.set(key.getMapping().getAttributeName(),keyElements[key.getIndex()]);
      }
    }
    entity=dynamicEntity;
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
  if (entity instanceof PersistenceEntity) {
    ((PersistenceEntity)entity)._persistence_setId(id);
  }
  if (entity instanceof FetchGroupTracker) {
    ((FetchGroupTracker)entity)._persistence_setSession(JpaHelper.getDatabaseSession(context.getEmf()));
  }
  return entity;
}

Fixed version (ground truth):
/** 
 * build a shell of an object based on a primary key.  The object shell will be an instance of the object with only primary key populated
 * @param context
 * @param entityType
 * @param id
 * @return
 */
public static Object buildObjectShell(PersistenceContext context,String entityType,Object id){
  ClassDescriptor descriptor=context.getDescriptor(entityType);
  List<DatabaseMapping> pkMappings=descriptor.getObjectBuilder().getPrimaryKeyMappings();
  Object entity=null;
  if (descriptor.hasCMPPolicy()) {
    CMP3Policy policy=(CMP3Policy)descriptor.getCMPPolicy();
    entity=policy.createBeanUsingKey(id,(AbstractSession)context.getJpaSession());
  }
 else   if (entity instanceof DynamicEntity) {
    DynamicEntityImpl dynamicEntity=(DynamicEntityImpl)context.newEntity(entityType);
    if (pkMappings.size() == 1) {
      dynamicEntity.set(pkMappings.get(0).getAttributeName(),id);
    }
 else {
      List<SortableKey> pkIndices=new ArrayList<SortableKey>();
      int index=0;
      for (      DatabaseMapping mapping : pkMappings) {
        pkIndices.add(new SortableKey(mapping,index));
        index++;
      }
      Collections.sort(pkIndices);
      Object[] keyElements=(Object[])id;
      for (      SortableKey key : pkIndices) {
        dynamicEntity.set(key.getMapping().getAttributeName(),keyElements[key.getIndex()]);
      }
    }
    entity=dynamicEntity;
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
  if (entity instanceof PersistenceEntity) {
    ((PersistenceEntity)entity)._persistence_setId(id);
  }
  if (entity instanceof FetchGroupTracker) {
    ((FetchGroupTracker)entity)._persistence_setSession(JpaHelper.getDatabaseSession(context.getEmf()));
  }
  return entity;
}