Skip to main content
3 of 4
added 8 characters in body
Mitesh Sura
  • 699
  • 1
  • 10
  • 21

Salesforce Selector layer - subquery

We have been using FF library for Separation of Concerns framework and it is working great. We need to add subquery to it, but running into issues. Example I am following is from this article: https://quirkyapex.com/2016/08/18/fflib-selector-layer/

public class OpportunityLineItemsSelector extends fflib_SObjectSelector {
 
   public Schema.SObjectType getSObjectType(){
      return OpportunityLineItem.sObjectType;
   }
 
   public override List<Schema.SObjectField> getSObjectFieldList(){
      return new List<Schema.SObjectField> {
         OpportunityLineItem.Id,
         OpportunityLineItem.Quantity,
         OpportunityLineItem.SalesPrice
      };
   }
 
}

public class OpportunitiesSelector extends fflib_SObjectSelector {
 
   public Schema.SObjectType getSObjectType(){
      return Opportunity.sObjectType;
   }
 
   public override List<Schema.SObjectField> getSObjectFieldList(){
      return new List<Schema.SObjectField> {
         Opportunity.Id,
         Opportunity.StageName
      };
   }
 
   public List<Opportunity> selectByIdWithLineItems(Set<Id> recordIds){
      fflib_QueryFactory query = newQueryFactory();
      query.setCondition('Id IN :recordIds');
      query.addQueryFactorySubselect( 
         new OpportunityLineItemsSelector().newQueryFactory() 
      );
      return (List<Opportunity>) Database.query( query.toSOQL() );
   }
 
}

I get compile error:

Method does not exist or incorrect signature: void addQueryFactorySubselect(fflib_QueryFactory) from the type fflib_QueryFactory at line 17 column 13

Below method does exist in "ev_SObjectSelector" class

global fflib__QueryFactory addQueryFactorySubselect(fflib__QueryFactory parentQueryFactory)
{
    return addQueryFactorySubselect(parentQueryFactory, true);
}

What am I missing here?

Mitesh Sura
  • 699
  • 1
  • 10
  • 21