Comments (1)
count这个简单,直接使用count函数就行了:
Specification<Person> countSpecification = Specifications.<Person>and()
.gt("timeCreated", new Date())
.build();
long count = personRepository.count(countSpecification);
top这个可以变相使用Page功能,使用new PageRequest(0, 15, sort)15的数据可以来自count的结果,也可以是个相对较大的结果,例如100:
public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.gt("timeCreated", new Date())
.build();
Sort sort = Sorts.builder()
.desc(StringUtils.isNotBlank(request.getName()), "name")
.asc("birthday")
.build();
return personRepository.findAll(specification, new PageRequest(0, 15, sort));
}
from jpa-spec.
Related Issues (20)
- in的体验不是特别号 HOT 2
- 关联查询时,每使用关联表的一个条件,就会多一个join HOT 4
- 假设查询参数可以为空的情况,如果不想拼接空的查询参数应该怎么写呢? HOT 1
- 关于select部分字段,以及各种数学运算,sum,max等和group by。jpa都是支持的 HOT 4
- 增加 boolean 值类型 Specification HOT 2
- join 使用in的时候报错java.sql.SQLException: ORA-25156: 旧样式的外部联接 (+) 不能与 ANSI 联接一起使用 HOT 2
- like模糊匹配不支持自定义escapeChar HOT 1
- 貌似不支持multiselect这种玩法 HOT 1
- 请问是否支持三级甚至更深层级查询? HOT 2
- 请教下如何求和(sum)运算? HOT 1
- 时间段查询sql不能解析成功 HOT 1
- 建议查询条件构建里面的values 提供Supplier重载
- PredicateBuilder.eq("fieldName") 不能按预期实现对字段值为null的判断
- mysql json HOT 2
- 项目真的很好 但是不在更新了吗
- jcenter 被弃用,作者最新的 3.2.5 版本的包放在哪个仓库的呀?
- How to search cross join table in @ManyToMany association and combine AND - OR condition in same query
- 建议PredicateBuilder类各个方法的property参数增加javax.persistence.metamodel.Attribute类型重载
- 会支持springboot3吗?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jpa-spec.