/**
* 条件-模糊-分页查询
* @param page
* @param rows
* @Auther: Mollen
* @return
*/
@Override
public Page<Employee> pageQuery(int page, int rows,Employee employee) {
//创建查询条件
ExampleMatcher matcher = ExampleMatcher.matching()
.withMatcher("employeeNum" ,ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("employeName" ,ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("dept" ,ExampleMatcher.GenericPropertyMatchers.contains())
.withMatcher("position" ,ExampleMatcher.GenericPropertyMatchers.contains());
//分页
PageRequest pageResult = PageRequest.of(page-1, rows);
return courierDao.findAll(Example.of(courier,matcher),pageResult);
}
JAVA编程132——springdata JPA使用Example快速实现动态查询
最新推荐文章于 2025-10-19 23:02:48 发布
本文介绍了一种使用Spring Data JPA实现的模糊分页查询方法,通过ExampleMatcher进行灵活匹配,提高了查询效率和准确性。
410

被折叠的 条评论
为什么被折叠?



