I've a Hibernate query:
StringBuilder sb = new StringBuilder("" +
"SELECT d.value " +
"FROM Table d " +
"WHERE d.date = :date ");
Query q = em.createQuery(sb.toString())
.setParameter("date",date);
BigDecimal result = (BigDecimal) q.getSingleResult();
if (result == null)
result = BigDecimal.ZERO;
return result;
When I pass date that exists in Table it works good, but when I pass Date that doesn't exists it returns an Exception
javax.persistence.NoResultException: No entity found for query
I've tried to put @NotFound(action = NotFoundAction.IGNORE) annotation under each filed of Table, but Exception is the same. How can I handle this problem?