Missing CrudRepository#findOne method

后端 未结 5 976
我在风中等你
我在风中等你 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:45

    We had many hundreds of usages of the old findOne() method. Rather than embark on a mammoth refactor, we ended up creating the following intermediary interface and had our repositories extend it instead of extending JpaRepository directly

    @NoRepositoryBean
    public interface BaseJpaRepository extends JpaRepository { 
        default T findOne(ID id) { 
            return (T) findById(id).orElse(null); 
        } 
    } 
    

提交回复
热议问题