Program: 177038
Project: 177038
Buggy source:
private void computeJoinTableRelations(Object entity,EntityMetadata entityMetadata,EntitySaveGraph objectGraph,PersistenceDelegator delegator,Relation relation){
  JoinTableMetadata jtMetadata=relation.getJoinTableMetadata();
  String joinTableName=jtMetadata.getJoinTableName();
  Set<String> joinColumns=jtMetadata.getJoinColumns();
  Set<String> inverseJoinColumns=jtMetadata.getInverseJoinColumns();
  String joinColumnName=(String)joinColumns.toArray()[0];
  String inverseJoinColumnName=(String)inverseJoinColumns.toArray()[0];
  EntityMetadata relMetadata=delegator.getMetadata(objectGraph.getChildClass());
  Client pClient=delegator.getClient(entityMetadata);
  List<?> foreignKeys=pClient.getForeignKeysFromJoinTable(joinTableName,joinColumnName,inverseJoinColumnName,relMetadata,objectGraph);
  List childrenEntities=new ArrayList();
  for (  Object foreignKey : foreignKeys) {
    try {
      EntityMetadata childMetadata=delegator.getMetadata(relation.getTargetEntity());
      Client childClient=delegator.getClient(childMetadata);
      Object child=childClient.find(relation.getTargetEntity(),childMetadata,(String)foreignKey,null);
      childrenEntities.add(child);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  Field childField=objectGraph.getProperty();
  try {
    PropertyAccessorHelper.set(entity,childField,PropertyAccessorHelper.isCollection(childField.getType()) ? getFieldInstance(childrenEntities,childField) : childrenEntities.get(0));
  }
 catch (  PropertyAccessException e) {
    e.printStackTrace();
  }
  System.out.println(entity);
}

Fixed version (ground truth):
private void computeJoinTableRelations(Object entity,EntityMetadata entityMetadata,EntitySaveGraph objectGraph,PersistenceDelegator delegator,Relation relation){
  objectGraph.setParentId(getId(entity,entityMetadata));
  JoinTableMetadata jtMetadata=relation.getJoinTableMetadata();
  String joinTableName=jtMetadata.getJoinTableName();
  Set<String> joinColumns=jtMetadata.getJoinColumns();
  Set<String> inverseJoinColumns=jtMetadata.getInverseJoinColumns();
  String joinColumnName=(String)joinColumns.toArray()[0];
  String inverseJoinColumnName=(String)inverseJoinColumns.toArray()[0];
  EntityMetadata relMetadata=delegator.getMetadata(objectGraph.getChildClass());
  Client pClient=delegator.getClient(entityMetadata);
  List<?> foreignKeys=pClient.getForeignKeysFromJoinTable(joinTableName,joinColumnName,inverseJoinColumnName,relMetadata,objectGraph);
  List childrenEntities=new ArrayList();
  for (  Object foreignKey : foreignKeys) {
    try {
      EntityMetadata childMetadata=delegator.getMetadata(relation.getTargetEntity());
      Client childClient=delegator.getClient(childMetadata);
      Object child=childClient.find(relation.getTargetEntity(),childMetadata,(String)foreignKey,null);
      childrenEntities.add(child);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  Field childField=objectGraph.getProperty();
  try {
    PropertyAccessorHelper.set(entity,childField,PropertyAccessorHelper.isCollection(childField.getType()) ? getFieldInstance(childrenEntities,childField) : childrenEntities.get(0));
  }
 catch (  PropertyAccessException e) {
    e.printStackTrace();
  }
  System.out.println(entity);
}