Program: 177047
Project: 177047
Buggy source:
/** 
 * Saves an object graph to persistence stores. An object graph contains a parent entity and one or more child entities at a time. There are other attributes too that represent their relationship. 
 * @param objectGraph the object graph
 */
private void saveGraph(EntitySaveGraph objectGraph){
  Object parentEntity=objectGraph.getParentEntity();
  EntityMetadata metadata=getMetadata(objectGraph.getParentClass());
  if (parentEntity != null) {
    objectGraph.setParentId(getId(parentEntity,metadata));
    if (getSession().lookup(parentEntity.getClass(),objectGraph.getParentId()) == null) {
      Client pClient=getClient(metadata);
      pClient.persist(objectGraph,metadata);
      session.store(objectGraph.getParentId(),objectGraph.getParentEntity());
    }
  }
  Object childEntity=objectGraph.getChildEntity();
  if (childEntity != null) {
    persistChildEntity(objectGraph,childEntity);
  }
  for (  Relation relation : metadata.getRelations()) {
    if (relation.isRelatedViaJoinTable()) {
      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=getMetadata(objectGraph.getChildClass());
      Client pClient=getClient(metadata);
      pClient.persistJoinTable(joinTableName,joinColumnName,inverseJoinColumnName,relMetadata,objectGraph);
    }
  }
}

Fixed version (ground truth):
/** 
 * Saves an object graph to persistence stores. An object graph contains a parent entity and one or more child entities at a time. There are other attributes too that represent their relationship. 
 * @param objectGraph the object graph
 */
private void saveGraph(EntitySaveGraph objectGraph){
  Object parentEntity=objectGraph.getParentEntity();
  EntityMetadata metadata=getMetadata(objectGraph.getParentClass());
  if (parentEntity != null) {
    objectGraph.setParentId(getId(parentEntity,metadata));
    Client pClient=getClient(metadata);
    pClient.persist(objectGraph,metadata);
    session.store(objectGraph.getParentId(),objectGraph.getParentEntity());
  }
  Object childEntity=objectGraph.getChildEntity();
  if (childEntity != null) {
    persistChildEntity(objectGraph,childEntity);
  }
  for (  Relation relation : metadata.getRelations()) {
    if (relation.isRelatedViaJoinTable()) {
      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=getMetadata(objectGraph.getChildClass());
      Client pClient=getClient(metadata);
      pClient.persistJoinTable(joinTableName,joinColumnName,inverseJoinColumnName,relMetadata,objectGraph);
    }
  }
}