Program: 168745
Project: 168745
Buggy source:
private <R>QuerySpecification getQuerySpecification(Query baseQuery,Query exampleQuery,String[] returningColumns,ReturningObjectBuilder<R> objectBuilder,Map<DbmsModificationState,String> includedModificationStates){
  Set<String> parameterListNames=parameterManager.getParameterListNames(baseQuery);
  Set<JoinNode> keyRestrictedLeftJoins=joinManager.getKeyRestrictedLeftJoins();
  List<String> keyRestrictedLeftJoinAliases=getKeyRestrictedLeftJoinAliases(baseQuery,keyRestrictedLeftJoins,Collections.EMPTY_SET);
  List<EntityFunctionNode> entityFunctionNodes=getEntityFunctionNodes(baseQuery);
  boolean isEmbedded=this instanceof ReturningBuilder;
  boolean shouldRenderCteNodes=renderCteNodes(isEmbedded);
  List<CTENode> ctes=shouldRenderCteNodes ? getCteNodes(baseQuery,isEmbedded) : Collections.EMPTY_LIST;
  ExtendedQuerySupport extendedQuerySupport=getService(ExtendedQuerySupport.class);
  Query insertExampleQuery=getInsertExampleQuery();
  String insertExampleSql=extendedQuerySupport.getSql(em,insertExampleQuery);
  String ownerAlias=extendedQuerySupport.getSqlAlias(em,insertExampleQuery,entityAlias);
  String targetAlias=extendedQuerySupport.getSqlAlias(em,insertExampleQuery,COLLECTION_BASE_QUERY_ALIAS);
  JoinTable joinTable=jpaProvider.getJoinTable(entityType,collectionName);
  int joinTableIndex=SqlUtils.indexOfTableName(insertExampleSql,joinTable.getTableName());
  String collectionAlias=SqlUtils.extractAlias(insertExampleSql,joinTableIndex + joinTable.getTableName().length());
  String[] selectItemExpressions=SqlUtils.getSelectItemExpressions(insertExampleSql,SqlUtils.indexOfSelect(insertExampleSql));
  Map<String,String> columnExpressionRemappings=new HashMap<>(selectItemExpressions.length);
  for (  Map.Entry<String,String> entry : joinTable.getKeyColumnMappings().entrySet()) {
    columnExpressionRemappings.put(collectionAlias + "String_Node_Str" + entry.getValue(),entry.getKey());
  }
  for (  Map.Entry<String,String> entry : joinTable.getIdColumnMappings().entrySet()) {
    columnExpressionRemappings.put(ownerAlias + "String_Node_Str" + entry.getValue(),entry.getKey());
  }
  for (  Map.Entry<String,String> entry : joinTable.getTargetColumnMappings().entrySet()) {
    columnExpressionRemappings.put(targetAlias + "String_Node_Str" + entry.getValue(),entry.getKey());
  }
  StringBuilder insertSqlSb=new StringBuilder();
  insertSqlSb.append("String_Node_Str").append(joinTable.getTableName()).append("String_Node_Str");
  for (  String selectItemExpression : selectItemExpressions) {
    insertSqlSb.append(columnExpressionRemappings.get(selectItemExpression.trim())).append(',');
  }
  insertSqlSb.setCharAt(insertSqlSb.length() - 1,')');
  if (returningColumns == null) {
    return new CollectionInsertModificationQuerySpecification(this,baseQuery,exampleQuery,parameterManager.getParameters(),parameterListNames,keyRestrictedLeftJoinAliases,entityFunctionNodes,mainQuery.cteManager.isRecursive(),ctes,shouldRenderCteNodes,isEmbedded,returningColumns,includedModificationStates,returningAttributeBindingMap,getInsertExecutorQuery(),insertSqlSb.toString());
  }
 else {
    return new ReturningCollectionInsertModificationQuerySpecification(this,baseQuery,exampleQuery,parameterManager.getParameters(),parameterListNames,keyRestrictedLeftJoinAliases,entityFunctionNodes,mainQuery.cteManager.isRecursive(),ctes,shouldRenderCteNodes,isEmbedded,returningColumns,includedModificationStates,returningAttributeBindingMap,getInsertExecutorQuery(),insertSqlSb.toString(),objectBuilder);
  }
}

Fixed version (ground truth):
private <R>QuerySpecification getQuerySpecification(Query baseQuery,Query exampleQuery,String[] returningColumns,ReturningObjectBuilder<R> objectBuilder,Map<DbmsModificationState,String> includedModificationStates){
  Set<String> parameterListNames=parameterManager.getParameterListNames(baseQuery);
  Set<JoinNode> keyRestrictedLeftJoins=joinManager.getKeyRestrictedLeftJoins();
  List<String> keyRestrictedLeftJoinAliases=getKeyRestrictedLeftJoinAliases(baseQuery,keyRestrictedLeftJoins,Collections.EMPTY_SET);
  List<EntityFunctionNode> entityFunctionNodes=getEntityFunctionNodes(baseQuery);
  boolean isEmbedded=this instanceof ReturningBuilder;
  boolean shouldRenderCteNodes=renderCteNodes(isEmbedded);
  List<CTENode> ctes=shouldRenderCteNodes ? getCteNodes(baseQuery,isEmbedded) : Collections.EMPTY_LIST;
  ExtendedQuerySupport extendedQuerySupport=getService(ExtendedQuerySupport.class);
  Query insertExampleQuery=getInsertExampleQuery();
  String insertExampleSql=extendedQuerySupport.getSql(em,insertExampleQuery);
  String ownerAlias=extendedQuerySupport.getSqlAlias(em,insertExampleQuery,entityAlias);
  String targetAlias=extendedQuerySupport.getSqlAlias(em,insertExampleQuery,COLLECTION_BASE_QUERY_ALIAS);
  JoinTable joinTable=jpaProvider.getJoinTable(entityType,collectionName);
  int joinTableIndex=SqlUtils.indexOfTableName(insertExampleSql,joinTable.getTableName());
  String collectionAlias=SqlUtils.extractAlias(insertExampleSql,joinTableIndex + joinTable.getTableName().length());
  String[] selectItemExpressions=SqlUtils.getSelectItemExpressions(insertExampleSql,SqlUtils.indexOfSelect(insertExampleSql));
  Map<String,String> columnExpressionRemappings=new HashMap<>(selectItemExpressions.length);
  if (joinTable.getKeyColumnMappings() != null) {
    for (    Map.Entry<String,String> entry : joinTable.getKeyColumnMappings().entrySet()) {
      columnExpressionRemappings.put(collectionAlias + "String_Node_Str" + entry.getValue(),entry.getKey());
    }
  }
  for (  Map.Entry<String,String> entry : joinTable.getIdColumnMappings().entrySet()) {
    columnExpressionRemappings.put(ownerAlias + "String_Node_Str" + entry.getValue(),entry.getKey());
  }
  for (  Map.Entry<String,String> entry : joinTable.getTargetColumnMappings().entrySet()) {
    columnExpressionRemappings.put(targetAlias + "String_Node_Str" + entry.getValue(),entry.getKey());
  }
  StringBuilder insertSqlSb=new StringBuilder();
  insertSqlSb.append("String_Node_Str").append(joinTable.getTableName()).append("String_Node_Str");
  for (  String selectItemExpression : selectItemExpressions) {
    insertSqlSb.append(columnExpressionRemappings.get(selectItemExpression.trim())).append(',');
  }
  insertSqlSb.setCharAt(insertSqlSb.length() - 1,')');
  if (returningColumns == null) {
    return new CollectionInsertModificationQuerySpecification(this,baseQuery,exampleQuery,parameterManager.getParameters(),parameterListNames,keyRestrictedLeftJoinAliases,entityFunctionNodes,mainQuery.cteManager.isRecursive(),ctes,shouldRenderCteNodes,isEmbedded,returningColumns,includedModificationStates,returningAttributeBindingMap,getInsertExecutorQuery(),insertSqlSb.toString());
  }
 else {
    return new ReturningCollectionInsertModificationQuerySpecification(this,baseQuery,exampleQuery,parameterManager.getParameters(),parameterListNames,keyRestrictedLeftJoinAliases,entityFunctionNodes,mainQuery.cteManager.isRecursive(),ctes,shouldRenderCteNodes,isEmbedded,returningColumns,includedModificationStates,returningAttributeBindingMap,getInsertExecutorQuery(),insertSqlSb.toString(),objectBuilder);
  }
}