@Override
    public <T extends PersistentObject> long count(Class<T> entityClass) {
        long count;
        CriteriaBuilder qb = em.getCriteriaBuilder();
        CriteriaQuery<Long> cq = qb.createQuery(Long.class);
        Root root = cq.from(entityClass);
        cq.select(qb.count(root));
        count = em.createQuery(cq).getSingleResult();
        return count;
    }