使用jpa查询的时候,如果查询不到数据,就会返回这个错误,下面是处理方法。

    @Override
    public User findByEmail(String email) {
        User user = new User();
        user.setEmail(email);
        Example<User> example = Example.of(user);
        Optional<User> optional = userDao.findOne(example);

        return optional.isPresent() ? optional.get(): null;
    }

 

相关文章:

  • 2019-01-21
  • 2021-08-02
  • 2021-07-28
  • 2021-11-17
  • 2021-11-05
  • 2021-10-26
  • 2022-01-10
猜你喜欢
  • 2022-12-23
  • 2021-09-22
  • 2021-05-29
  • 2022-01-07
  • 2022-12-23
  • 2021-10-20
相关资源
相似解决方案