为什么我不能保存这个SalesForce Batchable类?

时间:2012-03-10 15:52:35

标签: class save salesforce apex-code batch-processing

我目前正在使用Apex Workbook来刷新我对SalesForce的了解。

教程#15,第1课:提供以下代码:

global class CleanUpRecords implements Database.Batchable<Object>
{
    global final String query;

    global CleanUpRecords (String q) {query = q;}

    global Database.Querylocator start (Database.BatchableContext BC)
    {
           return Database.getQueryLocator(query);
    }    


    global void execute (Database.BatchableContext BC, List<sObject> scope)
    {
        delete scope;
        Database.emptyRecycleBin(scope);
    }    

    global void finish(Database.BatchableContext BC)
    {
        AsyncApexJob a = [
                SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email
                FROM AsyncApexJob 
                WHERE Id = :BC.getJobId()
            ];

        // Send an email to the Apex job's submitter
        // notifying of job completion.
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {a.CreatedBy.Email};
        mail.setToAddresses(toAddresses);
        mail.setSubject('Record Clean Up Completed ' + a.Status);
        mail.setPlainTextBody (
                'The batch Apex job processed ' + a.TotalJobItems +
                ' batches with '+ a.NumberOfErrors + ' failures.'
               );
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
    }

}

但是,无论我使用哪个开发界面(例如Force IDE,控制台,设置),当我尝试保存时,我得到:

Multiple markers at this line
    - File only saved locally, not to server
    - Save error: CleanUpRecords: Class must implement the global interface method: Iterable<Object> start(Database.BatchableContext) from Database.Batchable<Object>, CleanUpRecords: Class must implement the global interface method: void execute(Database.BatchableContext, LIST<Object>) from 
     Database.Batchable<Object>

(或者一些等价物,取决于我如何保存它。)

然而,在我看来,已经存在所需的方法。

缺少什么?

1 个答案:

答案 0 :(得分:9)

准备沮丧......只有一个角色。

您的课程声明应为:

global class CleanUpRecords implements Database.Batchable<sObject> {

而不是:

global class CleanUpRecords implements Database.Batchable<Object> {