use of org.broadleafcommerce.core.search.domain.SearchFacetRangeImpl in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetDaoImpl method readSearchFacetRangesForSearchFacet.
@Override
public List<SearchFacetRange> readSearchFacetRangesForSearchFacet(SearchFacet searchFacet) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SearchFacetRange> criteria = builder.createQuery(SearchFacetRange.class);
Root<SearchFacetRangeImpl> ranges = criteria.from(SearchFacetRangeImpl.class);
criteria.select(ranges);
Predicate facetRestriction = builder.equal(ranges.get("searchFacet"), searchFacet);
// if it hadn't
if (ArchiveStatus.class.isAssignableFrom(SearchFacetRangeImpl.class)) {
criteria.where(builder.and(facetRestriction, builder.or(builder.isNull(ranges.get("archiveStatus").get("archived").as(String.class)), builder.notEqual(ranges.get("archiveStatus").get("archived").as(Character.class), 'Y'))));
} else {
criteria.where(facetRestriction);
}
TypedQuery<SearchFacetRange> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Search");
try {
return query.getResultList();
} catch (NoResultException e) {
return new ArrayList<>();
}
}
Aggregations