throw new IllegalArgumentException("Category name is either null or blank");
} else
{
EntityTransaction tx = em.getTransaction();
tx.begin();
Category updatedCategory = em.find(Category.class, category.getId());
tx.commit();
if (updatedCategory == null)
{
LOGGER.error("(update) Provided Category does not exist");
throw new IllegalArgumentException("Provided Category does not exist");
}
updatedCategory.setName(category.getName());
tx.begin();
updatedCategory = em.merge(updatedCategory);
tx.commit();
return updatedCategory;
}