Search in sources :

Example 1 with ProductOptionValueImpl

use of org.broadleafcommerce.core.catalog.domain.ProductOptionValueImpl in project BroadleafCommerce by BroadleafCommerce.

the class ProductOptionDaoImpl method countAllowedValuesForProductOptionById.

@Override
public Long countAllowedValuesForProductOptionById(Long productOptionId) {
    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Long> criteria = builder.createQuery(Long.class);
    Root<ProductOptionValueImpl> root = criteria.from(ProductOptionValueImpl.class);
    criteria.select(builder.count(root));
    List<Predicate> restrictions = new ArrayList<>();
    List<Long> mergedIds = sandBoxHelper.mergeCloneIds(ProductOptionImpl.class, productOptionId);
    restrictions.add(root.get("productOption").in(mergedIds));
    criteria.where(restrictions.toArray(new Predicate[restrictions.size()]));
    TypedQuery<Long> query = em.createQuery(criteria);
    return query.getSingleResult();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) ArrayList(java.util.ArrayList) ProductOptionValueImpl(org.broadleafcommerce.core.catalog.domain.ProductOptionValueImpl) Predicate(javax.persistence.criteria.Predicate)

Aggregations

ArrayList (java.util.ArrayList)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 ProductOptionValueImpl (org.broadleafcommerce.core.catalog.domain.ProductOptionValueImpl)1