Elastic Path Commerce Development



The QueryService interface simplifies the process for creating new domain object queries. QueryService utilizes the Query Object Pattern, to enable users to generate customized queries without having to understand the details of the domain object database tables. QueryService automatically generates the Java Persistence Query Language (JPQL) required to access domain objects. QueryService builds the JPQL query from QueryCriteria objects that are mapped to domain object properties, so all a user needs to know are the properties of the domain object they are querying.

QueryService Components

The QueryService Interface

A call to QueryService has the following:

QueryResult<R> queryResult = queryServiceImpl<T>.query(QueryCriteria<T> criteria);

Three main components to the QueryService:

  • QueryResult
  • QueryService implementation
  • QueryCriteria


The QueryResult interface provides the methods for getting results from the query.

The generic type <R> depends on the type of result returned by the query. The QueryService interface requires you to specify the result's type. For more information on specifying the type, see Building a Query with QueryService.

QueryService Implementation

Each domain object has its own QueryService implementation. Out of the box, Elastic Path has the following QueryService implementations:

Domain Object QueryService implementation
ContentSpace ContentSpaceQueryService
ParameterValue ParameterValueQueryService
Product ProductQueryService


The QueryCriteria specifies the statements the query will perform. Refer to Building a Query with QueryService for more details.