Program: 177030
Project: 177030
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));
    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());
  List<EntitySaveGraph> relationGraphs=null;
  if (objectGraph.isIsswapped() && !metadata.getRelations().isEmpty()) {
    relationGraphs=getGraph(parentEntity,metadata);
    for (    EntitySaveGraph g : relationGraphs) {
      saveGraph(g);
    }
  }
  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);
    }
  }
}