Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why NoResultException?  RSS feed

K Karthik
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!