How do I catch a NoResultException after calling the getSingleResult() on a custom query, wich often doesn't return any result. Catching the NoResultException still logs an error (NoResultException: No entity found for query) and after that the Info is printed out. Happens both in the designer and on the server.

catch (NoResultException e) {
    Ivy.log().info("No Result has been found for Debitor '"+number+"'.");

haven't tested yet with other Exceptions like NonUniqueResultException.

Thank you in advance

This question is marked "community wiki".

asked 25.11.2014 at 16:35

Alexis's gravatar image

accept rate: 66%

If you are not sure if there is a single result available or if more than one result is available use the method getResultList() instead of getSingleResult(). Then check if the returning List is empty or contains more than one entry.


answered 26.11.2014 at 09:19

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
accept rate: 74%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 25.11.2014 at 16:35

Seen: 1,199 times

Last updated: 26.11.2014 at 09:19