QueryOptionsBuilder Class

Contains methods to build an immutable Database.QueryOptions instance.

Database

See the Usage section of the QueryOptions Class.

This example chains Data 360 options on the builder and runs a DLO query.

The following are methods for QueryOptionsBuilder.

Returns an immutable Database.QueryOptions object that reflects the current builder state.

public Database.QueryOptions build()

Type: Database.QueryOptions

An immutable Database.QueryOptions object that reflects the current builder state.

Sets the dataspace context for the query.

Use when querying Data 360 Data Lake Objects (DLOs). If a dataspace isn’t specified for a DLO query, the query returns zero records. Valid only for DLO queries. Not supported for data model object (DMO) queries. For more information, see SOQL SET OPTIONS in the SOQL and SOSL Reference.

public Database.QueryOptionsBuilder withDataspace(String value)

dataspaceName

Type: String

The dataspace name. This parameter is case-sensitive. Can’t be null or empty.

Type: Database.QueryOptionsBuilder

This Database.QueryOptionsBuilder instance.

Sets whether explicit namespace resolution is enabled for the query.

If true, unqualified custom field and relationship names resolve to subscriber fields, and namespace-qualified names resolve to packaged fields. Use this option in managed package Apex to avoid field-name shadowing conflicts with subscriber orgs. Setting this option to false is the same as leaving the option unset, meaning that package namespace shadowing is applied. See Prevent Field Name Collisions in Managed SOQL Queries in the Apex Developer Guide.

public Database.QueryOptionsBuilder withExplicitNamespace(Boolean bool)

bool

Type: Boolean

true to enable explicit namespace resolution, or false for namespace shadowing. Can't be null.

Type: Database.QueryOptionsBuilder

This Database.QueryOptionsBuilder instance.

Sets whether empty-string filter values are treated as meaningful rather than as null.

Supported for Data 360 virtual entities (DLOs). Also supports simple queries for DMOs. Salesforce Platform objects don’t distinguish between null and empty strings, so this option controls only Data 360 filter behavior. For more information, see SOQL SET OPTIONS in the SOQL and SOSL Reference.

withHonorEmptyStrings(true) isn’t supported for queries that include aggregate relationships, semi-joins, or foreign key relationships. Those queries throw System.QueryException at run time.

public Database.QueryOptionsBuilder withHonorEmptyStrings(Boolean value)

bool

Type: Boolean

true to treat null and empty strings as different values, or false to treat them the same, which is the default behavior of Salesforce Platform objects.

Type: Database.QueryOptionsBuilder

This Database.QueryOptionsBuilder instance.