Difference between findBy and findOneBy in Spring data JPA

后端 未结 3 803
半阙折子戏
半阙折子戏 2020-12-28 15:43

All i know so far is that FindBy can return multiple results while FindOneBy will return a single result or null when we use it the following way.

List

        
3条回答
  •  悲哀的现实
    2020-12-28 16:14

    findOneByXX will ensure that there is only one or no value, if there are 2 values an exception will be thrown.

    However findByXX doesn't make this check of uniqueness.

提交回复
热议问题