Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, MongoDB and SQL in Java.
Example for JPA:
List<Customer> result = query.from(customer) .where(customer.lastName.like("A%"), customer.active.eq(true)) .orderBy(customer.lastName.asc(), customer.firstName.desc()) .list(customer);
Compared to the alternatives Querydsl is more compact, safer and easier to learn. Try it today!
Instead of writing queries as inline strings or externalizing them into XML files they are constructed via a fluent API.
- Code completion in IDE (all properties, methods and operations can be expanded in your favorite Java IDE)
- Almost no syntactically invalid queries allowed (type-safe on all levels)
- Domain types and properties can be referenced safely (no Strings involved!)
- Adopts better to refactoring changes in domain types
- Incremental query definition is easier
Since 2.3.0 Querydsl is released under the Apache License, version 2.0.
Releases before 2.3.0 are licensed under the LGPL 2.1 license.
The following blog posts show Querydsl usage examples and will help you to get started. Reading relevant sections of the latest Reference Documentation will help you as well.