How to properly handle empty resultset with Hibernate and Spring Boot

后端 未结 2 2011
-上瘾入骨i
-上瘾入骨i 2021-02-09 18:10

I have a Spring app that is using Hibernate and the Spring Data JPA\'s CrudRepository. Everything seems to work properly if the data that was queried for exists in

2条回答
  •  爱一瞬间的悲伤
    2021-02-09 19:05

    None of the spring crud repository find methods throw an exception if no results are returned. They all return nulls. Since you are getting a null pointer exception on the server side you must be trying to perform an operation on the returned value without checking whether it's null first.

提交回复
热议问题