public boolean anyPendingExpenses() {
CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
CriteriaQuery<Boolean> cq = cb.createQuery(Boolean.class);
Root<Expense> expense_ = cq.from(Expense.class);
return getEntityManager().createQuery(
cq.distinct(true).where(
cb.equal(expense_.get("status"), Expense.Status.Submitted)
).multiselect(
cb.selectCase()
.when(cb.gt(cb.count(expense_), 0L), true)
.otherwise(false)
)
).getSingleResult();
}