Alecsandru Cocarla wrote:You should not throw RecordNotFoundException if there are no matching records
Roberto Perillo wrote:I disagree. I think this is exactly the purpose of this exception in this case. And honestly, I think it is much better than to return a 0-length array, for instance. An exception is not necessarily an error. You are right Payal, it does make more sense.
Alecsandru Cocarla wrote:If exceptions were so good when no records were found, they would have been used by relational databases and jdbc. They're not. Empty result sets are used for this very purpose.
Roberto Perillo wrote:There are no exceptions in the relational databases world. One thing is OO and another thing is relational databases. Also, ResultSets return data (from the relational databases world), not entities (from the OO world).
Roberto Perillo wrote:On the other hand, I looked at the JPA's javax.persistence.Query class API (which deals with entities), and saw that the getSingleResult method does throw a NoResultException if no results are found.