return em.find(Category.class, categoryId);
}
public Category findCategory(String categoryName) {
if (categoryName == null)
throw new ValidationException("Invalid category name");
TypedQuery<Category> typedQuery = em.createNamedQuery(Category.FIND_BY_NAME, Category.class);
typedQuery.setParameter("pname", categoryName);
return typedQuery.getSingleResult();
}