class ProductOptionValueServiceImpl extends
		SalesManagerEntityServiceImpl<Long, ProductOptionValue> implements
		ProductOptionValueService {

	@Inject
	private ProductAttributeService productAttributeService;
	
	@Autowired
	private PageableProductOptionValueRepository pageableProductOptionValueRepository;
	
	private ProductOptionValueRepository productOptionValueRepository;
	
	@Inject
	public ProductOptionValueServiceImpl(
			ProductOptionValueRepository productOptionValueRepository) {
			super(productOptionValueRepository);
			this.productOptionValueRepository = productOptionValueRepository;
	}
	
	
	@Override
	public List<ProductOptionValue> listByStore(MerchantStore store, Language language) throws ServiceException {
		
		return productOptionValueRepository.findByStoreId(store.getId(), language.getId());
	}
	
	@Override
	public List<ProductOptionValue> listByStoreNoReadOnly(MerchantStore store, Language language) throws ServiceException {
		
		return productOptionValueRepository.findByReadOnly(store.getId(), language.getId(), false);
	}

	@Override
	public List<ProductOptionValue> getByName(MerchantStore store, String name, Language language) throws ServiceException {
		
		try {
			return productOptionValueRepository.findByName(store.getId(), name, language.getId());
		} catch (Exception e) {
			throw new ServiceException(e);
		}
		
		
	}
	
	@Override
	public void saveOrUpdate(ProductOptionValue entity) throws ServiceException {
		
		
		//save or update (persist and attach entities
		if(entity.getId()!=null && entity.getId()>0) {

			super.update(entity);
			
		} else {
			
			super.save(entity);
			
		}
		
	}
	
	
	public void delete(ProductOptionValue entity) throws ServiceException {<FILL_FUNCTION_BODY>}
	
	@Override
	public ProductOptionValue getByCode(MerchantStore store, String optionValueCode) {
		return productOptionValueRepository.findByCode(store.getId(), optionValueCode);
	}


	@Override
	public ProductOptionValue getById(MerchantStore store, Long optionValueId) {
		return productOptionValueRepository.findOne(store.getId(), optionValueId);
	}


	@Override
	public Page<ProductOptionValue> getByMerchant(MerchantStore store, Language language, String name, int page,
			int count) {
	    Validate.notNull(store, "MerchantStore cannot be null");
	    Pageable p = PageRequest.of(page, count);
	    return pageableProductOptionValueRepository.listOptionValues(store.getId(), name, p);
	}



}

		
		//remove all attributes having this option
		List<ProductAttribute> attributes = productAttributeService.getByOptionValueId(entity.getMerchantStore(), entity.getId());
		
		for(ProductAttribute attribute : attributes) {
			productAttributeService.delete(attribute);
		}
		
		ProductOptionValue option = getById(entity.getId());
		
		//remove option
		super.delete(option);
		
	
<methods>public void <init>(JpaRepository<com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue,java.lang.Long>) ,public java.lang.Long count() ,public void create(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) throws com.salesmanager.core.business.exception.ServiceException,public void delete(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) throws com.salesmanager.core.business.exception.ServiceException,public void flush() ,public com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue getById(java.lang.Long) ,public List<com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue> list() ,public void save(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) throws com.salesmanager.core.business.exception.ServiceException,public void saveAll(Iterable<com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue>) throws com.salesmanager.core.business.exception.ServiceException,public void update(com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue) throws com.salesmanager.core.business.exception.ServiceException<variables>private Class<com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue> objectClass,private JpaRepository<com.salesmanager.core.model.catalog.product.attribute.ProductOptionValue,java.lang.Long> repository