@Test public void testGetByProductId() { ProductCategoryService productCategoryService = (ProductCategoryService) ctx().getBean(ServiceSpringKeys.PRODUCT_CATEGORY_SERVICE); EntityFactory entityFactory = productCategoryService.getGenericDao().getEntityFactory(); ProductService productService = (ProductService) ctx().getBean(ServiceSpringKeys.PRODUCT_SERVICE); ProductTypeService productTypeService = (ProductTypeService) ctx().getBean(ServiceSpringKeys.PRODUCT_TYPE_SERVICE); BrandService brandService = (BrandService) ctx().getBean(ServiceSpringKeys.BRAND_SERVICE); Product product = entityFactory.getByIface(Product.class); product.setCode("PROD_CODE"); product.setName("product"); product.setDescription("description"); product.setProducttype(productTypeService.findById(1L)); product.setBrand(brandService.findById(101L)); product = productService.create(product); assertTrue(product.getProductId() > 0); ProductCategory productCategory = entityFactory.getByIface(ProductCategory.class); productCategory.setProduct(product); productCategory.setCategory(categoryService.findById(128L)); productCategory.setRank(0); productCategory = productCategoryService.create(productCategory); assertTrue(productCategory.getProductCategoryId() > 0); productCategory = entityFactory.getByIface(ProductCategory.class); productCategory.setProduct(product); productCategory.setCategory(categoryService.findById(133L)); productCategory.setRank(0); productCategory = productCategoryService.create(productCategory); assertTrue(productCategory.getProductCategoryId() > 0); List<Category> list = categoryService.findByProductId(product.getProductId()); assertEquals(2, list.size()); }
@Override public List<Category> findByProductId(final long productId) { return categoryDao.findByNamedQuery( "CATEGORIES.BY.PRODUCTID", productId ); }
CategoryServiceImpl extends BaseGenericServiceImpl<Category> implements CategoryService { @Override public List<Category> findByProductId(final long productId) { return categoryDao.findByNamedQuery( "CATEGORIES.BY.PRODUCTID", productId ); } }
CategoryServiceImpl extends BaseGenericServiceImpl<Category> implements CategoryService { @Override public List<Category> findByProductId(final long productId) { return categoryDao.findByNamedQuery( "CATEGORIES.BY.PRODUCTID", productId ); } CategoryServiceImpl(final GenericDAO<Category, Long> categoryDao,
                               final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); }
CategoryServiceImpl extends BaseGenericServiceImpl<Category> implements CategoryService { @Override public List<Category> findByProductId(final long productId) { return categoryDao.findByNamedQuery( "CATEGORIES.BY.PRODUCTID", productId ); } CategoryServiceImpl(final GenericDAO<Category, Long> categoryDao,
                               final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); @Override Category getRootCategory(); @Override List<Long> getCategoryLinks(final long categoryId); @Override String getCategoryTemplate(final long categoryId); @Override String getCategorySearchTemplate(final long categoryId); @Override Long getCategoryProductTypeId(final long categoryId); @Override boolean isCategoryHasChildren(final long categoryId); @Override List<Category> getChildCategories(final long categoryId); @Override List<Category> findChildCategoriesWithAvailability(final long categoryId, final boolean withAvailability); @Override Set<Category> getChildCategoriesRecursive(final long categoryId); @Override Set<Long> getAllCategoryIds(final Collection<String> guids); @Override List<Long> getChildCategoriesRecursiveIds(final long categoryId); @Override List<Long> getChildCategoriesRecursiveIdsAndLinkIds(final long categoryId); @Override List<Category> findCategories(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findCategoryCount(final Map<String, List> filter); @Override List<Long> getCategoryIdAndLinkId(final long categoryId); @Override boolean isCategoryHasSubcategory(final long topCategoryId, final long subCategoryId); @Override Category getById(final long pk); @Override Long findCategoryIdBySeoUri(final String seoUri); @Override Long findCategoryIdByGUID(final String guid); @Override String findSeoUriByCategoryId(final Long categoryId); @Override Category findCategoryIdBySeoUriOrGuid(final String seoUriOrGuid); @Override List<Category> findByProductId(final long productId); CategoryService getSelf(); }
CategoryServiceImpl extends BaseGenericServiceImpl<Category> implements CategoryService { @Override public List<Category> findByProductId(final long productId) { return categoryDao.findByNamedQuery( "CATEGORIES.BY.PRODUCTID", productId ); } CategoryServiceImpl(final GenericDAO<Category, Long> categoryDao,
                               final ShopCategoryRelationshipSupport shopCategoryRelationshipSupport); @Override Category getRootCategory(); @Override List<Long> getCategoryLinks(final long categoryId); @Override String getCategoryTemplate(final long categoryId); @Override String getCategorySearchTemplate(final long categoryId); @Override Long getCategoryProductTypeId(final long categoryId); @Override boolean isCategoryHasChildren(final long categoryId); @Override List<Category> getChildCategories(final long categoryId); @Override List<Category> findChildCategoriesWithAvailability(final long categoryId, final boolean withAvailability); @Override Set<Category> getChildCategoriesRecursive(final long categoryId); @Override Set<Long> getAllCategoryIds(final Collection<String> guids); @Override List<Long> getChildCategoriesRecursiveIds(final long categoryId); @Override List<Long> getChildCategoriesRecursiveIdsAndLinkIds(final long categoryId); @Override List<Category> findCategories(final int start, final int offset, final String sort, final boolean sortDescending, final Map<String, List> filter); @Override int findCategoryCount(final Map<String, List> filter); @Override List<Long> getCategoryIdAndLinkId(final long categoryId); @Override boolean isCategoryHasSubcategory(final long topCategoryId, final long subCategoryId); @Override Category getById(final long pk); @Override Long findCategoryIdBySeoUri(final String seoUri); @Override Long findCategoryIdByGUID(final String guid); @Override String findSeoUriByCategoryId(final Long categoryId); @Override Category findCategoryIdBySeoUriOrGuid(final String seoUriOrGuid); @Override List<Category> findByProductId(final long productId); CategoryService getSelf();  }