Refine search
@Override public List<Customer> findAll(int page, int pageSize) { TypedQuery<Customer> query = em.createQuery("select c from Customer c", Customer.class); query.setFirstResult(page * pageSize); query.setMaxResults(pageSize); return query.getResultList(); }
@Override public List<Customer> findByLastname(String lastname, int page, int pageSize) { TypedQuery<Customer> query = em.createQuery("select c from Customer c where c.lastname = ?1", Customer.class); query.setParameter(1, lastname); query.setFirstResult(page * pageSize); query.setMaxResults(pageSize); return query.getResultList(); } }
@Override public List<Product> readAllProducts(int limit, int offset) { TypedQuery<Product> query = em.createNamedQuery("BC_READ_ALL_PRODUCTS", Product.class); //don't cache - could take up too much memory query.setFirstResult(offset); query.setMaxResults(limit); return query.getResultList(); }
@Override public List<Sku> readAllSkus(int offset, int limit) { TypedQuery<Sku> query = em.createNamedQuery("BC_READ_ALL_SKUS", Sku.class); //don't cache - could take up too much memory query.setFirstResult(offset); query.setMaxResults(limit); return query.getResultList(); }
@Override public List<Order> findCarts(String[] names, OrderStatus[] statuses, Date dateCreatedMinThreshold, Boolean isPreview, int startPos, int length, List<Long> excludedIds) { TypedQuery<Order> query = buildCartQuery(names, statuses, dateCreatedMinThreshold, isPreview, Order.class, excludedIds); query.setFirstResult(startPos); query.setMaxResults(length); return query.getResultList(); }
@Override public List<Customer> findCustomers(Date dateCreatedMinThreshold, Boolean registered, Boolean deactivated, Boolean isPreview, int startPos, int length, List<Long> excludedIds) { TypedQuery<Customer> query = buildCustomerQuery(dateCreatedMinThreshold, registered, deactivated, isPreview, Customer.class, excludedIds); query.setFirstResult(startPos); query.setMaxResults(length); return query.getResultList(); }
@Override public List<Product> readProductsByName(@Nonnull String searchName, @Nonnull int limit, @Nonnull int offset) { TypedQuery<Product> query = em.createNamedQuery("BC_READ_PRODUCTS_BY_NAME", Product.class); query.setParameter("name", searchName + '%'); query.setFirstResult(offset); query.setMaxResults(limit); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); return query.getResultList(); }
@Override public List<Category> readCategoriesByName(String categoryName, int limit, int offset) { TypedQuery<Category> query = em.createNamedQuery("BC_READ_CATEGORY_BY_NAME", Category.class); query.setParameter("categoryName", categoryName); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); query.setFirstResult(offset); query.setMaxResults(limit); return query.getResultList(); }
@Override public List<CustomerAddress> readBatchCustomerAddresses(int start, int pageSize) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<CustomerAddress> criteria = builder.createQuery(CustomerAddress.class); Root<CustomerAddressImpl> customer = criteria.from(CustomerAddressImpl.class); criteria.select(customer); TypedQuery<CustomerAddress> query = em.createQuery(criteria); query.setFirstResult(start); query.setMaxResults(pageSize); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.CustomerAddress"); return query.getResultList(); }
@Override public List<Customer> readBatchCustomers(int start, int pageSize) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Customer> criteria = builder.createQuery(Customer.class); Root<CustomerImpl> customer = criteria.from(CustomerImpl.class); criteria.select(customer); TypedQuery<Customer> query = em.createQuery(criteria); query.setFirstResult(start); query.setMaxResults(pageSize); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Customer"); return query.getResultList(); }
@Override public List<Category> readAllCategories(int limit, int offset) { TypedQuery<Category> query = em.createNamedQuery("BC_READ_ALL_CATEGORIES", Category.class); query.setFirstResult(offset); query.setMaxResults(limit); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); return query.getResultList(); }
@Override public List<Long> findProductIdsUsingProductOptionById(Long productOptionId, int start, int pageSize) { TypedQuery<Long> query = getProductIdsUsingProductOptionByIdQuery(productOptionId, false); query.setFirstResult(start); query.setMaxResults(pageSize); query.setHint(QueryHints.HINT_CACHEABLE, true); return query.getResultList(); }
public List<Product> readActiveProductsByCategoryInternal(Long categoryId, Date currentDate, int limit, int offset) { TypedQuery<Product> query = em.createNamedQuery("BC_READ_ACTIVE_PRODUCTS_BY_CATEGORY", Product.class); query.setParameter("categoryId", sandBoxHelper.mergeCloneIds(CategoryImpl.class, categoryId)); query.setParameter("currentDate", currentDate); query.setFirstResult(offset); query.setMaxResults(limit); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); return query.getResultList(); }
@Override public List<Product> readProductsByCategory(Long categoryId, int limit, int offset) { TypedQuery<Product> query = em.createNamedQuery("BC_READ_PRODUCTS_BY_CATEGORY", Product.class); query.setParameter("categoryId", sandBoxHelper.mergeCloneIds(CategoryImpl.class, categoryId)); query.setFirstResult(offset); query.setMaxResults(limit); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); return query.getResultList(); }
protected List<Sku> readAllActiveSkusInternal(int page, int pageSize, Date currentDate) { CriteriaQuery<Sku> criteria = getCriteriaForActiveSkus(currentDate); int firstResult = page * pageSize; TypedQuery<Sku> query = em.createQuery(criteria); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); return query.setFirstResult(firstResult).setMaxResults(pageSize).getResultList(); }
protected List<Product> readAllActiveProductsInternal(int page, int pageSize, Date currentDate) { CriteriaQuery<Product> criteria = getCriteriaForActiveProducts(currentDate); int firstResult = page * pageSize; TypedQuery<Product> query = em.createQuery(criteria); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); return query.setFirstResult(firstResult).setMaxResults(pageSize).getResultList(); }
@Override public <T> List<T> readAllGenericEntity(Class<T> clazz, int limit, int offset) { clazz = (Class<T>) DynamicDaoHelperImpl.getNonProxyImplementationClassIfNecessary(clazz); TypedQuery<T> q = new TypedQueryBuilder<T>(clazz, "root").toQuery(em); q.setMaxResults(limit); q.setFirstResult(offset); return q.getResultList(); }
@Override public List<Category> readAllSubCategories(Category category, int limit, int offset) { TypedQuery<Category> query = em.createNamedQuery("BC_READ_ALL_SUBCATEGORIES", Category.class); query.setParameter("parentCategoryId", sandBoxHelper.mergeCloneIds(CategoryImpl.class, category.getId())); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); query.setFirstResult(offset); query.setMaxResults(limit); return query.getResultList(); }
@Override public List<Category> readActiveSubCategoriesByCategory(Category category, int limit, int offset) { TypedQuery<Category> query = em.createNamedQuery("BC_READ_ACTIVE_SUBCATEGORIES_BY_CATEGORY", Category.class); query.setParameter("parentCategoryId", sandBoxHelper.mergeCloneIds(CategoryImpl.class, category.getId())); query.setParameter("currentDate", getCurrentDateAfterFactoringInDateResolution()); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Catalog"); query.setFirstResult(offset); query.setMaxResults(limit); return query.getResultList(); }
@Override public List<Order> readBatchOrders(int start, int pageSize, List<OrderStatus> statuses) { CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<Order> criteria = builder.createQuery(Order.class); Root<OrderImpl> order = criteria.from(OrderImpl.class); criteria.select(order); if (CollectionUtils.isNotEmpty(statuses)) { // We only want results that match the orders with the correct status ArrayList<String> statusStrings = new ArrayList<String>(); for (OrderStatus status : statuses) { statusStrings.add(status.getType()); } criteria.where(order.get("status").as(String.class).in(statusStrings)); } TypedQuery<Order> query = em.createQuery(criteria); query.setFirstResult(start); query.setMaxResults(pageSize); query.setHint(QueryHints.HINT_CACHEABLE, true); query.setHint(QueryHints.HINT_CACHE_REGION, "query.Order"); return query.getResultList(); }