Hello

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

Alexis
(suspended)
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.

link

answered 26.11.2014 at 09:19

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×32

Asked: 25.11.2014 at 16:35

Seen: 1,888 times

Last updated: 26.11.2014 at 09:19