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.
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:
- QueryService implementation
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.