Program: 168804
Project: 168804
Buggy source:
@Override @SuppressWarnings("String_Node_Str") protected TypedQuery<T> getTypedQuery(){
  Set<String> parameterListNames=new HashSet<String>();
  TypedQuery<T> leftMostQuery=(TypedQuery<T>)setOperationManager.getStartQueryBuilder().getTypedQueryForFinalOperationBuilder();
  TypedQuery<T> baseQuery;
  parameterManager.collectParameterListNames(leftMostQuery,parameterListNames);
  if (leftMostQuery instanceof CustomSQLQuery) {
    CustomSQLQuery customQuery=(CustomSQLQuery)leftMostQuery;
    List<Query> customQueryParticipants=customQuery.getParticipatingQueries();
    baseQuery=(TypedQuery<T>)customQueryParticipants.get(0);
  }
 else   if (leftMostQuery instanceof CustomSQLTypedQuery<?>) {
    CustomSQLTypedQuery<?> customQuery=(CustomSQLTypedQuery<?>)leftMostQuery;
    List<Query> customQueryParticipants=customQuery.getParticipatingQueries();
    baseQuery=(TypedQuery<T>)customQueryParticipants.get(0);
  }
 else {
    baseQuery=leftMostQuery;
  }
  List<Query> setOperands=new ArrayList<Query>();
  for (  AbstractCommonQueryBuilder<?,?,?,?,?> setOperand : setOperationManager.getSetOperations()) {
    Query q=setOperand.getQuery();
    setOperands.add(q);
    parameterManager.collectParameterListNames(q,parameterListNames);
  }
  String limit=null;
  String offset=null;
  if (firstResult != 0) {
    offset=Integer.toString(firstResult);
  }
  if (maxResults != Integer.MAX_VALUE) {
    limit=Integer.toString(maxResults);
  }
  Set<JoinNode> keyRestrictedLeftJoins=joinManager.getKeyRestrictedLeftJoins();
  List<String> keyRestrictedLeftJoinAliases=getKeyRestrictedLeftJoinAliases(baseQuery,keyRestrictedLeftJoins,Collections.EMPTY_SET);
  List<EntityFunctionNode> entityFunctionNodes=getEntityFunctionNodes(baseQuery);
  boolean shouldRenderCteNodes=renderCteNodes(false);
  List<CTENode> ctes=shouldRenderCteNodes ? getCteNodes(baseQuery,false) : Collections.EMPTY_LIST;
  QuerySpecification querySpecification=new SetOperationQuerySpecification(this,leftMostQuery,baseQuery,setOperands,setOperationManager.getOperator(),getOrderByElements(),setOperationManager.isNested(),parameterListNames,limit,offset,keyRestrictedLeftJoinAliases,entityFunctionNodes,mainQuery.cteManager.isRecursive(),ctes,shouldRenderCteNodes);
  @SuppressWarnings("String_Node_Str") TypedQuery<T> query=new CustomSQLTypedQuery<T>(querySpecification,baseQuery,new CommonQueryBuilderAdapter(this),cbf.getExtendedQuerySupport(),parameterManager.getValuesParameters(),parameterManager.getValuesBinders());
  if (selectManager.getSelectObjectBuilder() != null) {
    query=transformQuery(query);
  }
  return query;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") protected TypedQuery<T> getTypedQuery(){
  Set<String> parameterListNames=new HashSet<String>();
  TypedQuery<T> leftMostQuery=(TypedQuery<T>)setOperationManager.getStartQueryBuilder().getTypedQueryForFinalOperationBuilder();
  TypedQuery<T> baseQuery;
  parameterManager.collectParameterListNames(leftMostQuery,parameterListNames);
  if (leftMostQuery instanceof CustomSQLQuery) {
    CustomSQLQuery customQuery=(CustomSQLQuery)leftMostQuery;
    List<Query> customQueryParticipants=customQuery.getParticipatingQueries();
    baseQuery=(TypedQuery<T>)customQueryParticipants.get(0);
  }
 else   if (leftMostQuery instanceof CustomSQLTypedQuery<?>) {
    CustomSQLTypedQuery<?> customQuery=(CustomSQLTypedQuery<?>)leftMostQuery;
    List<Query> customQueryParticipants=customQuery.getParticipatingQueries();
    baseQuery=(TypedQuery<T>)customQueryParticipants.get(0);
  }
 else {
    baseQuery=leftMostQuery;
  }
  List<Query> setOperands=new ArrayList<Query>();
  for (  AbstractCommonQueryBuilder<?,?,?,?,?> setOperand : setOperationManager.getSetOperations()) {
    Query q=setOperand.getQuery();
    setOperands.add(q);
    parameterManager.collectParameterListNames(q,parameterListNames);
  }
  String limit=null;
  String offset=null;
  if (!isMainQuery) {
    if (firstResult != 0) {
      offset=Integer.toString(firstResult);
    }
    if (maxResults != Integer.MAX_VALUE) {
      limit=Integer.toString(maxResults);
    }
  }
  Set<JoinNode> keyRestrictedLeftJoins=joinManager.getKeyRestrictedLeftJoins();
  List<String> keyRestrictedLeftJoinAliases=getKeyRestrictedLeftJoinAliases(baseQuery,keyRestrictedLeftJoins,Collections.EMPTY_SET);
  List<EntityFunctionNode> entityFunctionNodes=getEntityFunctionNodes(baseQuery);
  boolean shouldRenderCteNodes=renderCteNodes(false);
  List<CTENode> ctes=shouldRenderCteNodes ? getCteNodes(baseQuery,false) : Collections.EMPTY_LIST;
  QuerySpecification querySpecification=new SetOperationQuerySpecification(this,leftMostQuery,baseQuery,setOperands,setOperationManager.getOperator(),getOrderByElements(),setOperationManager.isNested(),parameterListNames,limit,offset,keyRestrictedLeftJoinAliases,entityFunctionNodes,mainQuery.cteManager.isRecursive(),ctes,shouldRenderCteNodes);
  @SuppressWarnings("String_Node_Str") TypedQuery<T> query=new CustomSQLTypedQuery<T>(querySpecification,baseQuery,new CommonQueryBuilderAdapter(this),cbf.getExtendedQuerySupport(),parameterManager.getValuesParameters(),parameterManager.getValuesBinders());
  if (isMainQuery) {
    if (firstResult != 0) {
      query.setFirstResult(firstResult);
    }
    if (maxResults != Integer.MAX_VALUE) {
      query.setMaxResults(maxResults);
    }
  }
  if (selectManager.getSelectObjectBuilder() != null) {
    query=transformQuery(query);
  }
  return query;
}