Before I posted this question, I already looked this, but I couldn\'t get what I was looking for.
I know that for the query I wrote there may exist only one row or n
String hql="from DrawUnusedBalance where unusedBalanceDate= :today"; DrawUnusedBalance drawUnusedBalance = em.unwrap(Session.class) .createQuery(hql, DrawUnusedBalance.class) .setParameter("today",new LocalDate()) .uniqueResultOptional() .orElseThrow(NotFoundException::new);