Open-source project
querydsl/querydsl avatar
querydsl/querydsl

Querydsl: type-safe SQL-like queries for Java

Unified Queries for Java

4,972 stars882 forksJavaApache-2.0

At a glance

What is it?
Querydsl builds queries through a fluent Java API instead of inline strings or XML, with modules for JPA, SQL, MongoDB, Lucene and collections. It is a mature library, but the release cadence and the annotation-processing step are the two things to check before adopting it.
Who is it for?
Adopt Querydsl when you want compile-time checked queries over JPA or plain SQL and you can accept an annotation-processing step in your build. Do not adopt it if you need a small dependency surface, if your queries are mostly static and can live in Spring Data derived methods, or if you are on a stack where jOOQ's code generation from the database schema fits better.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 125 days ago.
What is it written in?
Mainly Java, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem Querydsl solves for Java persistence code

Java persistence code has three common ways to express a query: a string, an XML file, or a criteria API. Strings and XML are not checked until runtime, so a renamed column or a typo in a join condition surfaces as an exception in production. Querydsl takes a different route. The README states that the framework enables "the construction of type-safe SQL-like queries for multiple backends including JPA, MongoDB and SQL in Java," and that queries are "constructed via a fluent API" rather than inline strings or externalized XML.

The audience is narrow but real. It is for Java teams that already have a domain model and want query construction to fail at compile time when the model changes. It is also for teams that need the same query style across more than one backend, since the repository carries separate modules for JPA, SQL, MongoDB, Lucene, collections, JDO, spatial queries and Hibernate Search. A team that only ever writes CRUD against one table does not need this.

How the fluent API and Q-types fit together

The mechanism visible in the repository is code generation plus a fluent builder. The top-level tree contains querydsl-apt, querydsl-codegen and querydsl-codegen-utils, which is where the annotation processing and source generation live. Querydsl JPA is not a runtime query engine of its own; the JPA module is a front end that produces a query the JPA provider executes. The SQL module is the one that talks to a database directly. MongoDB and Lucene sit alongside them as separate backends rather than behind a shared execution layer.

The practical consequence is a build-time dependency on generated types. Your entities are processed, static query types (commonly called Q-types) are emitted, and your query code refers to those generated classes. That is what makes a field rename a compile error instead of a runtime failure. It also means the generated sources are part of your build output and your IDE has to be told where they are, which is the usual source of friction in a new setup.

Installing Querydsl and running a first JPA query

The README points to Maven Central releases rather than a manual download, and the getting-started links for JPA, SQL and MongoDB are hosted on the project site. The README does not print the dependency coordinates itself; it only shows the Maven Central badge for com.querydsl/querydsl-core. The one build command it does give is the source build, with a Maven profile per backend. The profile name is one of jpa, sql, mongodb and so on, or all.

bash
$ mvn -Pquickbuild,{projectname} clean install

Contributors running Querydsl's own tests can start the database containers the repository ships in docker-compose.yml. The file lists MySQL on 3306, PostgreSQL on 5433, Oracle on 1521, MongoDB on 27017 and DB2 on 50000, among others. None of these containers are needed to use the library in your own application.

bash
$ docker-compose up -d

For a first real query, the pattern is to obtain the generated Q-type for your entity and pass it to a query object. The README does not reproduce a full example inline; it links to the Querying JPA tutorial for that. What the repository does show is that the JPA integration is a documented, first-class path rather than a side module. After the build runs, you should see generated Q-classes under your build output directory, and query code should compile against them.

Where Querydsl gets in the way

The build-time generation step is the main cost. It adds an annotation processor to every module that queries the database, and it interacts with your IDE, your incremental compiler and any other processor you already run. When the generated types are stale, the errors are confusing because the compiler complains about a missing class rather than about a changed field.

The second limitation is release cadence. Version 5.0.0 was released on 2021-07-22 and 5.1.0 on 2024-01-29. The repository's last push was on 2026-05-28, so the codebase is not abandoned, but the gap between 5.0.0 and 5.1.0 is roughly two and a half years. Anyone planning to depend on Querydsl for a long-lived product should read that interval as the realistic tempo for fixes and new features rather than assume a steady stream.

The third case is when Querydsl is simply the wrong tool. If your queries are a handful of derived finder methods, Spring Data already gives you those without a processor. If you need full control over generated SQL and are willing to generate from the database schema instead of the entity model, jOOQ is the closer fit. And if you only query collections in memory, the querydsl-collections module exists but the value of the generated types is much lower there.

Querydsl compared with jOOQ and the JPA Criteria API

The comparison people search for is Querydsl against jOOQ. Both generate Java types you query against, but the source of truth differs. Querydsl generates from your JPA entities or your own annotated classes, so the query model follows the object model. jOOQ generates from the database schema, so the query model follows the tables. That difference decides a lot: if your schema is the contract and you want SQL-shaped code, jOOQ's approach is more direct. If your entities are the contract and you want JPQL-shaped queries, Querydsl fits better.

The other comparison is against the JPA Criteria API, which ships with JPA and needs no extra dependency or processor. Criteria is type-safe too, but the builder style is verbose and reads poorly for anything beyond a simple predicate. Querydsl's fluent API is the reason many teams switch. The trade is a build-time dependency and a generated source tree in exchange for shorter query code.

Against Spring Data specifications the split is similar. A Specification is a function that builds a Criteria predicate, so it composes well inside Spring Data repositories without extra tooling. Querydsl gives you a fuller query language, including joins, projections and updates, at the cost of the processor.

Maintenance, upgrades and the Apache-2.0 licence

The repository is not archived, and the last push was on 2026-05-28. The release history shows 5.0.0.M1 on 2021-06-16, 5.0.0 on 2021-07-22 and 5.1.0 on 2024-01-29, so upgrades arrive in large, infrequent steps rather than as a steady drip. Treat a major version bump as a migration project: check the CHANGELOG.md at the repository root before moving, because that is where the project records what changed between releases.

The licence is Apache-2.0, with the LICENSE.txt file at the repository root. That is a permissive licence, and it is the same licence family most Java shops already accept for their other dependencies. Whether it fits your organisation's policy, and what obligations attach to redistribution, is a question for your legal team rather than something this article can settle.

The README also documents how to contribute, through GitHub pull requests, and asks that questions go to the Discussion Section or StackOverflow rather than the issue tracker. That matters for upgrade planning: if a release breaks something, the documented support channels are the discussions area and the querydsl tag on StackOverflow, not the issue list.

Editorial conclusion

Adopt Querydsl when you want compile-time checked queries over JPA or plain SQL and you can accept an annotation-processing step in your build. Do not adopt it if you need a small dependency surface, if your queries are mostly static and can live in Spring Data derived methods, or if you are on a stack where jOOQ's code generation from the database schema fits better. Before committing, verify that a 5.1.0 artifact for your backend module resolves from Maven Central, that your annotation processor runs on your JDK and build tool, and that the generated Q-types are produced for every entity you intend to query.

Frequently asked questions

How can I use Querydsl in a Spring Boot application?

Add the com.querydsl artifacts from Maven Central, including the annotation processor, then build so the Q-types are generated. The README links to a Querying JPA tutorial for the full JPA setup rather than reproducing it inline.

What are some alternatives to Querydsl?

The two closest comparisons are jOOQ, which generates query types from the database schema rather than from entities, and the JPA Criteria API, which ships with JPA and needs no processor but is more verbose. Spring Data specifications are another option when your queries fit inside repositories.

What is Querydsl used for?

The README describes it as a framework for constructing type-safe SQL-like queries for multiple backends including JPA, MongoDB and SQL in Java, using a fluent API instead of inline strings or XML. The repository also carries modules for collections, Lucene, JDO, spatial queries and Hibernate Search.

Is Querydsl dead or deprecated?

The repository is not archived and its last push was on 2026-05-28, so it is not abandoned. The release history is sparse, though: 5.0.0 shipped on 2021-07-22 and 5.1.0 on 2024-01-29, so plan for infrequent releases rather than a steady cadence.

How does Querydsl compare with the JPA Criteria API?

Both are type-safe, but Criteria ships with JPA and needs no extra dependency or annotation processor, while Querydsl requires generated Q-types at build time. In exchange, Querydsl's fluent API produces shorter query code than the Criteria builder style.

Official sources

  1. License: Apache-2.0
  2. Project website
  3. querydsl/querydsl on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/querydsl-querydsl.svg)](https://hysenlabs.com/projects/querydsl-querydsl)