use of org.broadleafcommerce.core.search.domain.SearchFacetImpl in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetDaoImpl method readAllSearchFacets.
@Override
public List<SearchFacet> readAllSearchFacets(FieldEntity entityType) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SearchFacet> criteria = builder.createQuery(SearchFacet.class);
Root<SearchFacetImpl> facet = criteria.from(SearchFacetImpl.class);
criteria.select(facet);
criteria.where(builder.equal(facet.get("showOnSearch").as(Boolean.class), true), facet.join("fieldType").join("indexField").join("field").get("entityType").as(String.class).in(entityType.getAllLookupTypes()));
TypedQuery<SearchFacet> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Search");
return query.getResultList();
}
use of org.broadleafcommerce.core.search.domain.SearchFacetImpl in project BroadleafCommerce by BroadleafCommerce.
the class SearchFacetDaoImpl method readSearchFacetForField.
@Override
public SearchFacet readSearchFacetForField(Field field) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SearchFacet> criteria = builder.createQuery(SearchFacet.class);
Root<SearchFacetImpl> facet = criteria.from(SearchFacetImpl.class);
criteria.select(facet);
criteria.where(builder.equal(facet.join("fieldType").join("indexField").join("field").get("id").as(Long.class), field.getId()));
TypedQuery<SearchFacet> query = em.createQuery(criteria);
query.setHint(QueryHints.HINT_CACHEABLE, true);
query.setHint(QueryHints.HINT_CACHE_REGION, "query.Search");
try {
return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
Aggregations