public Integer getCategoryId() { Category category = product.getCategory(); if (category == null) { return null; } else { return category.getId(); } }
public void setCategoryId(Integer categoryId) { if (categoryId == null) { product.setCategory(null); } else { for (Category category : categories) { if (category.getId().equals(categoryId)) { product.setCategory(category); break; } } } }