Missing CrudRepository#findOne method

后端 未结 5 979
我在风中等你
我在风中等你 2020-12-02 07:00

I am using Spring 5 in my project. Until today there was available method CrudRepository#findOne.

But after downloading latest snapshot it suddenly disappeared! Is t

5条回答
  •  既然无缘
    2020-12-02 07:50

    Note that findById is not an exact replacement for findOne, it returns an Optional instead of null.

    Being not very familiar with new java things it took me a little while to figure out, but this turns the findById behavior into the findOne one:

    return rep.findById(id).orElse(null);
    

提交回复
热议问题