resultList = dao.coreDao + .getQuery(em, "o", null, "o.id = :id", Map.of("id", id), dao.type, null, false, null, readTenantIds) + .getResultList(); + if (resultList.isEmpty()) + return null; + return resultList.get(0); + }); + } + + /** + * Get the selected entity or throw an exception if it wasn't found. + * + * @return the selected entity + */ + public P getOrException() { return withEntityManager(em -> dao.coreDao .getQuery(em, "o", null, "o.id = :id", Map.of("id", id), dao.type, null, false, null, readTenantIds) .getSingleResult());