a and (b or c) <==> (a and b) or (a and c)

UserExample userExample = new UserExample();
String email = user.getEmail();
String telephone = user.getTelephone();
userExample.createCriteria().andIdNotEqualTo(userId).andEmailEqualTo(email);//(id != 'a' and email = 'b')
if (StringUtils.isNotBlank(telephone)) {
	Criteria criteria = userExample.createCriteria().andIdNotEqualTo(userId).andTelephoneEqualTo(telephone);//(id != 'a' and telephone = 'c')
	userExample.or(criteria);//(id != 'a' and email = 'b') or (id != 'a' and telephone = 'c')
}
List<User> userList = userService.selectByExample(userExample);

 

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-26
  • 2022-12-23
  • 2022-02-27
猜你喜欢
  • 2022-12-23
  • 2021-04-12
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案