11 Mayıs 2015 Pazartesi

About JPA NoResultException

Hi,

Today I looked for NoResultException, wondered when it may occurs, found that,

If you search record with getSingleResult, NoResultException is thrown, because, as written at stackoverflow,

"If getSingleResult() would return null, you could not tell whether the query did not match any row or whether the query matched a row but the selected column contains null as its value"

Otherwise, if you search with query, the return object will be null(or if you cast result to List, it will be empty), so you should deal with null or empty list in this situation.

Link: http://stackoverflow.com/questions/1579560/why-in-jpa-entitymanager-queries-throw-noresultexception-but-find-does-not

Have a nice day !

Hiç yorum yok:

Yorum Gönder