= QueryDSL

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


link:http://querydsl.com/[QueryDSL] provides a way to express queries independently of the particular persistence mechanism, abstracting out whether the ORM in use is xref:pjdo:ROOT:about.adoc[JDO] or xref:pjpa:ROOT:about.adoc[JPA].

Apache Causeway's integration with QueryDSL provides the following capabilities:

* xref:refguide:persistence:index/querydsl/applib/services/repo/QueryDslRepository.adoc[]
+
Intended to be subclassed (it is `abstract`), and parameterized by the entity and its corresponding "Q" query class, this class provides a set of finder methods for a specified entity.
+
These finder methods take queries written as QueryDSL expressions.
More discussion on writing queries can be found xref:example-queries.adoc[here].
+
Internally, this class delegates to xref:refguide:persistence:index/querydsl/applib/services/support/QueryDslSupport.adoc[].

* xref:refguide:persistence:index/querydsl/applib/services/support/QueryDslSupport.adoc[] and xref:refguide:persistence:index/querydsl/applib/services/support/DetachedQueryFactory.adoc[]
+
Provides the mechanism to construct arbitrary queries against any entity.
+
The query expressions from xref:refguide:persistence:index/querydsl/applib/services/support/QueryDslSupport.adoc[] are attached, meaning they can be submitted directly to the database.
Those from xref:refguide:persistence:index/querydsl/applib/services/support/DetachedQueryFactory.adoc[] are detached; they cannot be submitted directly.
Instead, they are intended to be combined with the attached queries, e.g. in subqueries.
+
Although xref:refguide:persistence:index/querydsl/applib/services/support/QueryDslSupport.adoc[] itself is abstract, both the xref:pjpa::about.adoc[JPA] and xref:pjdo::about.adoc[JDO] persistence mechanisms provide concrete implementations.

* xref:refguide:persistence:index/querydsl/applib/services/auto/AutoCompleteGeneratedQueryService.adoc[]
+
Primarily used internally to provide support for autocomplete (using xref:refguide:applib:index/annotation/Property.adoc[@Property] and optionally xref:refguide:applib:index/annotation/DomainObject.adoc[@DomainObject]).
However, the service can also be called directly by the application if required.
+
More discussion on using the annotations can be found xref:autocomplete-annotations.adoc[here].

