Program: 175969
Project: 175969
Buggy source:
/** 
 * Parse and append cql3 token function for iter.next() call.
 * @param translator            cql translator.
 * @param query the query
 * @return parsed/append cql3 query.
 */
private String prepareNext(CQLTranslator translator,String query){
  if (checkOnEmptyResult()) {
    String idName=((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName();
    Map<Boolean,String> filterOnId=getConditionOnIdColumn(idName);
    if (filterOnId.get(true) != null) {
      String condition=filterOnId.get(true);
      if (condition.equals("String_Node_Str")) {
        return null;
      }
 else       if (condition.endsWith("String_Node_Str") || condition.equals("String_Node_Str")) {
        query=replaceAppliedToken(query);
        return query;
      }
    }
    Object entity=results.get(results.size() - 1);
    Class idClazz=((AbstractAttribute)entityMetadata.getIdAttribute()).getBindableJavaType();
    Object id=PropertyAccessorHelper.getId(entity,entityMetadata);
    StringBuilder builder=new StringBuilder(CQLTranslator.TOKEN);
    MetamodelImpl metaModel=(MetamodelImpl)kunderaMetadata.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
    EmbeddableType keyObj=null;
    String columnName;
    if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
      keyObj=metaModel.embeddable(entityMetadata.getIdAttribute().getBindableJavaType());
      Field embeddedField=getPartitionKeyField();
      Attribute partitionKey=keyObj.getAttribute(embeddedField.getName());
      Object partitionKeyValue=PropertyAccessorHelper.getObject(id,(Field)partitionKey.getJavaMember());
      columnName=((AbstractAttribute)partitionKey).getJPAColumnName();
      id=partitionKeyValue;
      idClazz=((AbstractAttribute)partitionKey).getBindableJavaType();
    }
 else {
      columnName=CassandraUtilities.getIdColumnName(kunderaMetadata,entityMetadata,externalProperties,((CassandraClientBase)client).isCql3Enabled(entityMetadata));
    }
    translator.appendColumnName(builder,columnName);
    builder.append(CQLTranslator.CLOSE_BRACKET);
    builder.append("String_Node_Str");
    builder.append(CQLTranslator.TOKEN);
    translator.appendValue(builder,idClazz,id,false,false);
    builder.append(CQLTranslator.CLOSE_BRACKET);
    return builder.toString();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Parse and append cql3 token function for iter.next() call.
 * @param translator cql translator.
 * @param query the query
 * @return parsed/append cql3 query.
 */
private String prepareNext(CQLTranslator translator,String query){
  if (checkOnEmptyResult()) {
    String idName=((AbstractAttribute)entityMetadata.getIdAttribute()).getJPAColumnName();
    Map<Boolean,String> filterOnId=getConditionOnIdColumn(idName);
    if (filterOnId.get(true) != null) {
      String condition=filterOnId.get(true);
      if (condition.equals("String_Node_Str")) {
        return null;
      }
 else       if (condition.endsWith("String_Node_Str") || condition.equals("String_Node_Str")) {
        query=replaceAppliedToken(query);
        return query;
      }
    }
    Object entity=results.get(results.size() - 1);
    Class idClazz=((AbstractAttribute)entityMetadata.getIdAttribute()).getBindableJavaType();
    Object id=PropertyAccessorHelper.getId(entity,entityMetadata);
    StringBuilder builder=new StringBuilder(CQLTranslator.TOKEN);
    MetamodelImpl metaModel=(MetamodelImpl)kunderaMetadata.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());
    EmbeddableType keyObj=null;
    String columnName=null;
    if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType())) {
      keyObj=metaModel.embeddable(entityMetadata.getIdAttribute().getBindableJavaType());
      Field embeddedField=getPartitionKeyField();
      Attribute partitionKey=keyObj.getAttribute(embeddedField.getName());
      Object partitionKeyValue=PropertyAccessorHelper.getObject(id,(Field)partitionKey.getJavaMember());
      columnName=((AbstractAttribute)partitionKey).getJPAColumnName();
      id=partitionKeyValue;
      idClazz=((AbstractAttribute)partitionKey).getBindableJavaType();
    }
 else {
      columnName=CassandraUtilities.getIdColumnName(kunderaMetadata,entityMetadata,externalProperties,((CassandraClientBase)client).isCql3Enabled(entityMetadata));
    }
    translator.appendColumnName(builder,columnName);
    builder.append(CQLTranslator.CLOSE_BRACKET);
    builder.append("String_Node_Str");
    builder.append(CQLTranslator.TOKEN);
    translator.appendValue(builder,idClazz,id,false,false);
    builder.append(CQLTranslator.CLOSE_BRACKET);
    return builder.toString();
  }
  return null;
}