Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCJP 1.4 100%
SCJD 99.5%
Alecsandru Cocarla wrote:You should not throw RecordNotFoundException if there are no matching records
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
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.
SCJP 1.4 100%
SCJD 99.5%
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.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
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.
SCJP 1.4 100%
SCJD 99.5%
Thanks
---------------------------------------
Naveen Hegde, SCJP5.0, SCJD...
---------------------------------------
SCJP 1.4 100%
SCJD 99.5%
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
I'm gonna teach you a lesson! Start by looking at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|