Jpa创建筛选器自动忽略nul值进行搜索

Jpa创建筛选器自动忽略nul值进行搜索

//创建一个筛选器
ExampleMatcher exampleMatcher = ExampleMatcher.matching().withMatcher("code", ExampleMatcher.GenericPropertyMatchers.contains().startsWith()).withIgnoreNullValues().withMatcher("name", ExampleMatcher.GenericPropertyMatchers.contains());
Person person=new Person();
person.setCode(code);
person.setName(name);
Example<Person> example=Example.of(person,exampleMatcher);
List<Person> personList=personRepository.findAll(example);
作者: JaminYe
版权声明:本文原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文地址:https://www.cnblogs.com/JaminYe/p/13388015.html