- Dynamic query
- Pagination and sorting
- Selecting specific columns
- JDK version >= 8
- Gradle
SelectQuery query = entityQuery.SelectQuery(User.class);
Condition c = query.getCondition();
Page dataList = query.select("name", "age").where(
c.greaterThanOrEqualTo("age", 25)
).getResult(pageable);
NormalQuery query = entityQuery.NormalQuery(User.class);
Condition c = query.getCondition();
Page dataList = query.select().where(
c.equal("sex", "male"),
c.greaterThan("age", 22)
).getResult(pageable);
NormalQuery query = entityQuery.NormalQuery(User.class);
Condition c = query.getCondition();
String sex = null;
Page dataList = query.select().where(
c.equal("sex", sex),
c.greaterThan("age", 22)
).getResult(pageable);
query.getWhere().add(c.greaterThan("age", 22));
Set ageSet = new HashSet<>();
ageSet.add(22);
ageSet.add(27);
Page dataList = query.select().where(
c.in("age", ageSet)
).getResult(pageable);
See more detail in src/test/java/xyz/defe/springDataJpa/test/SimplifyQueryTest.java