SpringDataJPA-Specification
使用Specification可以构建动态查询
原生的使用起来有点复杂,这里推介一个别人封装好的工具包
这里是github的地址
https://github.com/wenhao/jpa-spec/blob/master/README_CN.md
<!-- https://mvnrepository.com/artifact/com.github.wenhao/jpa-spec -->
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.2.4</version>
</dependency>
具体用法
方法 | 含义 |
---|---|
gt/ge | greater than/greater equal ,大于/大于等于 |
lt/le | less than/less equal,小于/小于等于 |
eq/ne | equal/not equal, 等于/不等于 |
in/notIn | 包含/不包含 |
like/notLike | like/notLike |
between | between |
基础查询均支持三个参数或者两个参数