@SuppressWarnings("unchecked")
    protected <T> Optional<T> getOne(TypedQuery<T> query) {
        List<T> resultList = (List<T>) query.getResultList();

        if (resultList.size() > 1) {
            throw new IllegalStateException("More than one result for query");
        }

        if (resultList.size() == 0) {
            return Optional.empty();
        }

        return Optional.of(resultList.get(0));
    }
Applies the criteria found in the {@link SearchCriteriaBean} to the JPA query.
@return
manager/api/jpa/src/main/java/io/apiman/manager/api/jpa/AbstractJpaStorage.java