public void updateCategoryParent(String categoryName, String parentCategoryName) { Category find = categoryDAL.findCategoryByName(categoryName); if (find == null) { throw CategoryException.CategoryNonExistException(categoryName); } Category parent = categoryDAL.findCategoryByName(parentCategoryName); if (parent == null) { throw CategoryException.parentCategoryNotExistException(parentCategoryName); } find.setParent(parent); categoryDAL.merge(find); }
public void updateCategoryParent(long categoryId, long parentCategoryId) { Category find = categoryDAL.find(Category.class, categoryId); if (find == null) { throw CategoryException.CategoryNonExistException(categoryId); } Category parent = categoryDAL.find(Category.class, categoryId); if (parent == null) { throw CategoryException.parentCategoryNotExistException(parentCategoryId); } find.setParent(parent); categoryDAL.merge(find); }