Skip to content

IF_Queryable

Class · Group: Query Infrastructure

apex
global interface IF_Queryable

Known Derived Types: QRY_Builder.Builder, SEL_ApiCall, SEL_ApiIssue, SEL_Base, SEL_ContentVersion, SEL_EmailTemplate, SEL_Foobar, SEL_Group, SEL_OrgWideEmailAddress, SEL_PermissionSet, SEL_PermissionSetGroup, SEL_Profile, SEL_User, SEL_UserRole, QRY_Builder.Builder.count(), SEL_Base.count(), QRY_Builder.Builder.exists(), SEL_Base.exists(), QRY_Builder.Builder.getFirst(), SEL_Base.getFirst(), QRY_Builder.Builder.toList(), SEL_Base.toList(), QRY_Builder.Builder.toQueryLocator(), SEL_Base.toQueryLocator()

Interface for any object that can execute a query. Implemented by QRY_Builder.Builder and SEL_Base. Allows polymorphic query execution across framework components such as batch jobs, async processors, and purge utilities.

Since: 1.0

Example:

apex
public class MyQueryable implements IF_Queryable
{
    public List<SObject> toList() { return query.toList(); }
    public SObject getFirst() { return query.getFirst(); }
    public Database.QueryLocator toQueryLocator() { return query.toQueryLocator(); }
    public Integer count() { return query.count(); }
    public Boolean exists() { return query.exists(); }
}

See Also: QRY_Builder, SEL_Base


Methods

MethodDescription
global abstract Integer count()Returns the count of matching records.
global abstract Boolean exists()Returns true if any records match the query.
global abstract SObject getFirst()Executes the query and returns the first matching record, or null.
global abstract List toList()Executes the query and returns all matching records.
global abstract Database.QueryLocator toQueryLocator()Returns a QueryLocator for batch processing.

Method Details

count

apex
global abstract Integer count()

Returns the count of matching records.

Returns: Integer - Number of matching records

Since: 1.0

exists

apex
global abstract Boolean exists()

Returns true if any records match the query.

Returns: Boolean - True if at least one record matches

Since: 1.0

getFirst

apex
global abstract SObject getFirst()

Executes the query and returns the first matching record, or null.

Returns: SObject - First matching SObject or null

Since: 1.0

toList

apex
global abstract List<SObject> toList()

Executes the query and returns all matching records.

Returns: SObject - List of matching SObjects

Since: 1.0

toQueryLocator

apex
global abstract Database.QueryLocator toQueryLocator()

Returns a QueryLocator for batch processing.

Returns: Database.QueryLocator - QueryLocator for this query

Since: 1.0