Chapter 16. The Infinispan Query DSL
16.1. Creating Queries with Infinispan Query DSL
QueryFactoryinstance, which is obtained using
QueryFactoryinstance is bound to the one cache instance, and is a stateless and thread-safe object that can be used for creating multiple parallel queries.
- A query is created by invocating the
from(Class entityType)method, which returns a
QueryBuilderobject that is responsible for creating queries for the specified entity class from the given cache.
QueryBuilderaccumulates search criteria and configuration specified through invoking its DSL methods, and is used to build a
Queryobject by invoking the
QueryBuilder.build()method, which completes the construction. The
QueryBuilderobject cannot be used for constructing multiple queries at the same time except for nested queries, however it can be reused afterwards.
- Invoke the
list()method of the
Queryobject to execute the query and fetch the results. Once executed, the
Queryobject is not reusable. If new results must be fetched, a new instance must be obtained by calling