public List<T> findByNamedQuery(String queryName,
                                    Map<String, Object> attributes) {
        Query query = em.createNamedQuery(queryName, entityClass);
        for (String s : attributes.keySet()) {
            query.setParameter(s, attributes.get(s));
        }
        return query.getResultList();
    }