我从APex类调用apex Batch,但它只调用批处理的构造函数,不调用start,execute和finish?

问题描述:

在Salesforce中,我从Apex类调用apex Batch,但它只调用批处理的构造函数,不调用start,execute和finish?到底是怎么回事?我从APex类调用apex Batch,但它只调用批处理的构造函数,不调用start,execute和finish?

我从类中调用这样的批处理。

ExportBatchClass EXPBTCH = new ExportBatchClass(); 
Database.executeBatch(EXPBTCH); 

,批量为:

global class ExportBatchClass implements Database.Batchable <Sobject> , Database.Stateful { 
    public String qryString; 

    global ExportBatchClass(){} 

    global ExportBatchClass(String qryString1){ 
     qryString=qryString1; 
     System.debug('qryString======'+qryString);  
    }  //END ExportBatchClass // 

    // Start Method 
    global Database.QueryLocator start(Database.BatchableContext BC){ 
     qryString='SELECT Product__r.name From Products__c WHERE Name != null ORDER by Product__r.Name ASC'; 

     system.debug('########## in START qryString = '+qryString); 
     return Database.getQueryLocator(qryString); 
    } 

    // Execute Logic 
    global void execute(Database.BatchableContext BC, List<Sobject> scope) { 
     for(Sobject s : scope) 
     { 
     Products__c pro=(Products__c)s; 
     productRelateListBatch.add(pro); 
     } 
     System.debug('productRelateListBatch======'+productRelateListBatch.size()); 
    } 

    global void finish(Database.BatchableContext BC){ 

    } 
} 

我缺少什么?

+0

代码中没有问题,请交叉检查您的数据库查询。 –

+0

你将什么分配给'qryString1' – Reshma

谢谢Q !!我解决了它。我只是重新构建它,代码现在可以正常工作。