O'Reilly logo

Force.com Enterprise Architecture by Andrew Fawcett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the custom query logic

If we take a look at the implementation of the fflib_SObjectSelector.selectSObjectById base class method (at the time of writing this book), it is quite simple and gives a template as to the way we can implement custom Selector methods; it also highlights other base class methods we can use:

public List<SObject> selectSObjectsById(Set<Id> idSet)
{
  assertIsAccessible();
  return Database.query(buildQuerySObjectById());
}
private String buildQuerySObjectById()
{ 
  return String.format(
    'SELECT {0} FROM {1} WHERE id in :idSet ORDER BY {2}', 
     new List<String> 
       {getFieldListString(),getSObjectName(),getOrderBy()}); 
}

The getFieldListString method calls the getSObjectFieldList and getSObjectFieldSetList methods implemented ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required