Hi,
I have done a refactoring of my code introducing EntityQuery/EntityHome. Basically, I have refactored out the following code into a EntityQuery defined in XML.
final Query query = mEntityManager.createQuery("SELECT e FROM Day e WHERE e.date = ?1 AND e.customer = ?2");
Day day = null;
query.setParameter(1, pDate.toCalendar(LocaleSelector.instance().
getLocale()));
query.setParameter(2, pCustomer);The problem now is, that the transaction get's rolled back despite I have catched the NoResultException what was not the case before.
Did I miss something?
@Override
public Boolean hasDay(final DateTime pDate, final Customer pCustomer) {
Validate.notNull(pDate, "Argument pDate is mandatory");
Validate.notNull(pCustomer, "Argument pCustomer is mandatory");
Boolean hasDay = Boolean.FALSE;
if (null != loadDay(pCustomer, pDate)) {
hasDay = Boolean.TRUE;
}
return hasDay;
}
@Override
public Day loadDay(final Customer pCustomer, final DateTime pDate) {
Validate.notNull(pCustomer, "Argument pCustomer is mandatory");
Validate.notNull(pDate, "Argument pDate is mandatory");
try {
mSelectedDay = mDayQuery.getSingleResult();
} catch (final NoResultException pException) {
mLog.debug("Day (date=#0) not found.", pException, pDate);
} catch (final NonUniqueResultException pException) {
mLog.error("Day (date=#0) more than one found!", pException, pDate);
}
return mSelectedDay;Thanks,
Cyrill