Program: 176744
Project: 176744
Buggy source:
/** 
 * Flushes Dirty objects in   {@link PersistenceCache} to databases.
 */
public void flush(){
  Deque<Node> fs=flushManager.getFlushStack();
  log.debug("String_Node_Str" + fs);
  if (fs != null) {
    boolean isBatch=false;
    while (!fs.isEmpty()) {
      Node node=fs.pop();
      if (node.isInState(ManagedState.class) || node.isInState(RemovedState.class)) {
        EntityMetadata metadata=getMetadata(node.getDataClass());
        node.setClient(getClient(metadata));
        if ((node.getClient() instanceof Batcher) && ((Batcher)(node.getClient())).getBatchSize() > 0) {
          isBatch=true;
          ((Batcher)(node.getClient())).addBatch(node);
        }
 else         if (flushMode.equals(FlushModeType.AUTO) || enableFlush) {
          if (isTransactionInProgress && defaultTransactionSupported(metadata.getPersistenceUnit())) {
            onSynchronization(node,metadata);
          }
 else {
            node.flush();
          }
        }
        Map<NodeLink,Node> parents=node.getParents();
        Map<NodeLink,Node> children=node.getChildren();
        if (parents != null && !parents.isEmpty()) {
          for (          NodeLink parentNodeLink : parents.keySet()) {
            parentNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,node.getEntityId());
          }
        }
        if (children != null && !children.isEmpty()) {
          for (          NodeLink childNodeLink : children.keySet()) {
            childNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,node.getEntityId());
          }
        }
      }
    }
    if (!isBatch) {
      flushJoinTableData();
    }
  }
}

Fixed version (ground truth):
/** 
 * Flushes Dirty objects in   {@link PersistenceCache} to databases.
 */
public void flush(){
  Deque<Node> fs=flushManager.getFlushStack();
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + fs);
  }
  if (fs != null) {
    boolean isBatch=false;
    while (!fs.isEmpty()) {
      Node node=fs.pop();
      if (node.isInState(ManagedState.class) || node.isInState(RemovedState.class)) {
        EntityMetadata metadata=getMetadata(node.getDataClass());
        node.setClient(getClient(metadata));
        if ((node.getClient() instanceof Batcher) && ((Batcher)(node.getClient())).getBatchSize() > 0) {
          isBatch=true;
          ((Batcher)(node.getClient())).addBatch(node);
        }
 else         if (flushMode.equals(FlushModeType.AUTO) || enableFlush) {
          if (isTransactionInProgress && defaultTransactionSupported(metadata.getPersistenceUnit())) {
            onSynchronization(node,metadata);
          }
 else {
            node.flush();
          }
        }
        Map<NodeLink,Node> parents=node.getParents();
        Map<NodeLink,Node> children=node.getChildren();
        if (parents != null && !parents.isEmpty()) {
          for (          NodeLink parentNodeLink : parents.keySet()) {
            parentNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,node.getEntityId());
          }
        }
        if (children != null && !children.isEmpty()) {
          for (          NodeLink childNodeLink : children.keySet()) {
            childNodeLink.addLinkProperty(LinkProperty.LINK_VALUE,node.getEntityId());
          }
        }
      }
    }
    if (!isBatch) {
      flushJoinTableData();
    }
  }
}