aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Why NoResultException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Why NoResultException?" Watch "Why NoResultException?" New topic
Author

Why NoResultException?

K Karthik
Greenhorn

Joined: Jul 05, 2007
Posts: 11
I was wondering as why javax.persistence.Query class throws NoResultException on calling getSingleResult() or getResultList() when there is no results? Won't it be more logical if they return 'null'? Also, rather than making NoResultException to be caught mandatory, they have made it a runtime exception. Since it is very common for a query to return no results, this should have been made a mandatory exception, if at all they are going to throw it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Why NoResultException?