File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why NoResultException?
 
Similar Threads
NoResultException
getSingleResult returns NPE
instanceof doubt
Distinguish a NoResultException, from an InvocationTargetException
urlyBird 1.2.3 - findByCriteria method