惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 阿木申

iOS收到Push后播放声音和震动 [vb]sendkeys [vb]键盘精灵 - 阿木申 - 博客园 javascript 画带箭头的线段 关于input type='file'的内容的一种解决方法,模拟键盘 - 阿木申 - 博客园 防止IE缓存,就相当于IE选择每次打开就检查 - 阿木申 - 博客园 [dojo] 解决传中文的乱码问题 - 阿木申 - 博客园 [dojo] dojo.xhrGet和.net整合使用 [dojo]好用的页面对话框dijit.Dialog [dojo]日期选择:dijit.form.DateTextbox [dojo]功能强大的文本框:dijit.form.ValidationTextbox - 阿木申 - 博客园 dojo0.9 dojo.data研究笔记 [dojo] dojo 0.9 的使用心得 [原创]jBPM 子流程的使用 [原创]jBPM动态生成任务实例,会签或者分派任务时特别有用 [dojo转]动态生成widget [原创]jBpm中泳道使用心得 [原创]jBPM中的Expression和script [原创]JBPM中的基本操作代码
spring JPA 动态查询
阿木申 · 2016-11-04 · via 博客园 - 阿木申

没什么好说的,记住就行。

下面是在Service中的方法

Page<TStaff> staffs=dao.findAll(new Specification<TStaff>() {
			
			@Override
			public Predicate toPredicate(Root<TStaff> root, CriteriaQuery<?> query,
					CriteriaBuilder cb) {
				Predicate predicate = cb.conjunction();
	            List<Expression<Boolean>> expressions = predicate.getExpressions();
				
				if(StringUtils.isNotEmpty(loginName)){
					expressions.add(cb.equal(root.<String>get("loginName"), loginName));
				}
				if(StringUtils.isNotEmpty(email)){
					expressions.add(cb.equal(root.get("email").as(String.class), email));
				}
				if(StringUtils.isNotEmpty(groupDn)){
					expressions.add(cb.like(root.<String>get("groupDn"), "%"+groupDn));
				}
				
				return predicate;
			}
		}, new PageRequest(page.getCurPage(), page.getPageSize()));

dao定义如下:

public interface StaffDao extends Repository<TStaff, String>,JpaSpecificationExecutor<TStaff>