Java and SQL : return null or throw exception?

前端 未结 6 989
面向向阳花
面向向阳花 2021-01-21 10:09

This is another debated subject, but this time i am searching only for the simple and documented answers. The scenario :

Let\'s assume the following method:



        
6条回答
  •  隐瞒了意图╮
    2021-01-21 10:41

    If an error occurs, thow an exception. If there's no data, return an empty collection, not a null. (Also, generally you should return the more generic 'Map', not the specific implementation),

提交回复
热议问题