Querydsl - Unified Queries for Java
Unified Queries for Java.
Querydsl is compact, safe
and easy to learn.
Modules
JPA
The popular choice for SQL persistence with a focus on CRUD and simple queries for object loading. more...
SQL
The alternative SQL abstraction with a focus on SQL operations and the full expressivity of the SQL standard. more...
Mongodb
ODM support via Morphia or Spring Data for MongoDB, the NoSQL of choice for many. more...
Documentation
Examples
Basic query
List<Person> persons = queryFactory.selectFrom(person)
.where(
person.firstName.eq("John"),
person.lastName.eq("Doe"))
.fetch();
Order
List<Person> persons = queryFactory.selectFrom(person)
.orderBy(person.lastName.asc(),
person.firstName.desc())
.fetch();
Subqueries
List<Person> persons = queryFactory.selectFrom(person)
.where(person.children.size().eq(
JPAExpressions.select(parent.children.size().max())
.from(parent)))
.fetch();
Tuple projection
List<Tuple> tuples = queryFactory.select(
person.lastName, person.firstName, person.yearOfBirth)
.from(person)
.fetch();