Program: 96762
Project: 96762
Buggy source:
@Override protected void doTxWork(IProgressMonitor monitor,JdbcConnection connection) throws OseeCoreException {
  if (artifactsToPurge == null || artifactsToPurge.isEmpty()) {
    return;
  }
  checkPurgeValid(connection);
  Set<Artifact> childreArtifactsToPurge=new HashSet<>();
  for (  Artifact art : artifactsToPurge) {
    childreArtifactsToPurge.addAll(art.getDescendants(DeletionFlag.INCLUDE_DELETED));
  }
  artifactsToPurge.addAll(childreArtifactsToPurge);
  Id4JoinQuery artJoin2=JoinUtility.createId4JoinQuery(getJdbcClient());
  try {
    for (    Artifact art : artifactsToPurge) {
      artJoin2.add(art.getBranch(),art,TransactionId.SENTINEL,art.getBranch().getViewId());
    }
    artJoin2.store(connection);
    int queryId=artJoin2.getQueryId();
    TransactionJoinQuery txJoin=JoinUtility.createTransactionJoinQuery(getJdbcClient());
    insertSelectItems(txJoin,connection,"String_Node_Str","String_Node_Str",queryId);
    insertSelectItems(txJoin,connection,"String_Node_Str","String_Node_Str",queryId);
    insertSelectItems(txJoin,connection,"String_Node_Str","String_Node_Str",queryId);
    try {
      txJoin.store(connection);
      getJdbcClient().runPreparedUpdate(connection,DELETE_FROM_TXS_USING_JOIN_TRANSACTION,txJoin.getQueryId());
      getJdbcClient().runPreparedUpdate(connection,DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION,txJoin.getQueryId());
    }
  finally {
      txJoin.delete(connection);
    }
    for (    Artifact artifact : artifactsToPurge) {
      ArtifactCache.deCache(artifact);
      RelationManager.deCache(artifact);
      artifact.internalSetDeleted();
      for (      RelationLink rel : artifact.getRelationsAll(DeletionFlag.EXCLUDE_DELETED)) {
        rel.markAsPurged();
      }
      for (      Attribute<?> attr : artifact.internalGetAttributes()) {
        attr.markAsPurged();
      }
    }
    success=true;
  }
  finally {
    artJoin2.delete(connection);
  }
}

Fixed version (ground truth):
@Override protected void doTxWork(IProgressMonitor monitor,JdbcConnection connection) throws OseeCoreException {
  if (artifactsToPurge == null || artifactsToPurge.isEmpty()) {
    return;
  }
  checkPurgeValid(connection);
  Set<Artifact> childreArtifactsToPurge=new HashSet<>();
  for (  Artifact art : artifactsToPurge) {
    childreArtifactsToPurge.addAll(art.getDescendants(DeletionFlag.INCLUDE_DELETED));
  }
  artifactsToPurge.addAll(childreArtifactsToPurge);
  Id4JoinQuery artJoin2=JoinUtility.createId4JoinQuery(getJdbcClient());
  try {
    for (    Artifact art : artifactsToPurge) {
      artJoin2.add(art.getBranch(),art,TransactionId.SENTINEL,art.getBranch().getViewId());
    }
    artJoin2.store(connection);
    int queryId=artJoin2.getQueryId();
    TransactionJoinQuery txJoin=JoinUtility.createTransactionJoinQuery(getJdbcClient());
    insertSelectItems(txJoin,connection,"String_Node_Str","String_Node_Str",queryId);
    insertSelectItems(txJoin,connection,"String_Node_Str","String_Node_Str",queryId);
    insertSelectItems(txJoin,connection,"String_Node_Str","String_Node_Str",queryId);
    try {
      txJoin.store(connection);
      getJdbcClient().runPreparedUpdate(connection,DELETE_FROM_TXS_USING_JOIN_TRANSACTION,txJoin.getQueryId());
      getJdbcClient().runPreparedUpdate(connection,DELETE_FROM_TX_DETAILS_USING_JOIN_TRANSACTION,txJoin.getQueryId());
    }
  finally {
      txJoin.delete(connection);
    }
    BranchId branch=artifactsToPurge.iterator().next().getBranch();
    artifactEvent=new ArtifactEvent(branch);
    for (    Artifact artifact : artifactsToPurge) {
      EventBasicGuidArtifact guidArt=new EventBasicGuidArtifact(EventModType.Purged,artifact);
      artifactEvent.addArtifact(guidArt);
      for (      RelationLink rel : artifact.getRelationsAll(DeletionFlag.EXCLUDE_DELETED)) {
        DefaultBasicUuidRelation guidRelation=new DefaultBasicUuidRelation(branch,rel.getRelationType().getId(),rel.getId(),rel.getGammaId(),new DefaultBasicGuidArtifact(branch,rel.getArtifactA().getArtifactTypeId(),rel.getArtifactA()),new DefaultBasicGuidArtifact(branch,rel.getArtifactB().getArtifactTypeId(),rel.getArtifactB()));
        artifactEvent.addRelation(new EventBasicGuidRelation(RelationEventType.Purged,rel.getAArtifactId(),rel.getBArtifactId(),guidRelation));
        rel.markAsPurged();
      }
      for (      Attribute<?> attr : artifact.internalGetAttributes()) {
        attr.markAsPurged();
      }
      ArtifactCache.deCache(artifact);
      RelationManager.deCache(artifact);
      artifact.internalSetDeleted();
    }
    success=true;
  }
  finally {
    artJoin2.delete(connection);
  }
}