Page 1 of 1

Defect in ProductDaoImpl 3.0.0-SNAPSHOT

Posted: Mon Jun 10, 2013 12:46 pm
by Sanhi
Hi,

I'm new to the Broadleaf Framework and experimenting with extending the Demo Site with some new features. Great architecture, I must say!

I do believe I stepped on a defect today, while disabling the SolrSearchService and defaulting to the DatabaseSearchService I was confronted with an obsolete Join in the ProductDaoImpl.

Code: Select all

 @Override
    public List<Product> readFilteredActiveProductsByCategory(Long categoryId, Date currentDate,
            ProductSearchCriteria searchCriteria) {
        // Set up the criteria query that specifies we want to return Products
        CriteriaBuilder builder = em.getCriteriaBuilder();
        CriteriaQuery<Product> criteria = builder.createQuery(Product.class);
       
        // The root of our search is Category since we are browsing
        Root<CategoryImpl> category = criteria.from(CategoryImpl.class);
       
        // We want to filter on attributes from product and sku
        Join<Category, Product> product = category.join("allProducts");
        Join<Product, Sku> sku = product.join("defaultSku");
       
        // Product objects are what we want back
        criteria.select(product);
       
        // We only want results from the determine category
        List<Predicate> restrictions = new ArrayList<Predicate>();
        restrictions.add(builder.equal(category.get("id"), categoryId));
       
        attachProductSearchCriteria(searchCriteria, product, sku, restrictions);
       
        attachActiveRestriction(currentDate, product, sku, restrictions);
       
        attachOrderBy(searchCriteria, product, sku, criteria);
       
        // Execute the query with the restrictions
        criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
        return em.createQuery(criteria).getResultList();
    }


The Join to 'allProducts' seems to be removed, and will return a "Unable to resolve attribute [allProducts] against path" when browsing through the front-end categories.

Not sure what the best approach would be to fix this?

Re: Defect in ProductDaoImpl 3.0.0-SNAPSHOT

Posted: Mon Jun 10, 2013 1:22 pm
by phillipuniverse
Thanks for the report and glad you like the architecture!

Could you open this as an issue in GitHub? This will help us and you track progress better: https://github.com/BroadleafCommerce/Br ... rce/issues.

Thanks!

Re: Defect in ProductDaoImpl 3.0.0-SNAPSHOT

Posted: Mon Jun 10, 2013 1:48 pm
by Sanhi
Done, issue #81.

Re: Defect in ProductDaoImpl 3.0.0-SNAPSHOT

Posted: Wed Jun 12, 2013 1:26 am
by phillipuniverse
Thanks a bunch for the report! For anyone watching this thread I'm continuing the conversation on the GH issue at https://github.com/BroadleafCommerce/Br ... /issues/81