Interface CategoryDao

All Known Implementing Classes:
CategoryDaoImpl

public interface CategoryDao
CategoryDao provides persistence access to Category instances.
Author:
Jeff Fischer
See Also:
  • Method Details

    • readCategoryById

      @Nonnull Category readCategoryById(@Nonnull Long categoryId)
      Retrieve a Category instance by its primary key
      Parameters:
      categoryId - the primary key of the Category
      Returns:
      the Category at the specified primary key
    • readCategoriesByIds

      List<Category> readCategoriesByIds(List<Long> categoryIds)
      Retrieves a List of Category IDs
      Parameters:
      categoryIds -
      Returns:
    • readCategoryByExternalId

      Category readCategoryByExternalId(@Nonnull String externalId)
      Retrieve a Category instance by the external id
      Parameters:
      externalId -
      Returns:
    • readCategoryByName

      @Nonnull @Deprecated(forRemoval=true) Category readCategoryByName(@Nonnull String categoryName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Retrieve a Category instance by its name.

      Broadleaf allows more than one category to have the same name. Calling this method could produce an exception in such situations. Use readCategoriesByName(String) instead.

      Parameters:
      categoryName - the name of the category
      Returns:
      the Category having the specified name
    • readCategoriesByName

      @Nonnull List<Category> readCategoriesByName(@Nonnull String categoryName)
      Retrieve a list of Category instances by name.
      Parameters:
      categoryName - the name to search by
      Returns:
      the Category instances having the specified name
    • readCategoriesByName

      @Nonnull List<Category> readCategoriesByName(@Nonnull String categoryName, int limit, int offset)
    • readCategoriesByNames

      @Nonnull List<Category> readCategoriesByNames(List<String> names)
    • save

      @Nonnull Category save(@Nonnull Category category)
      Persist a Category instance to the datastore
      Parameters:
      category - the Category instance
      Returns:
      the updated state of the passed in Category after being persisted
    • readAllCategories

      @Nonnull List<Category> readAllCategories()
      Retrieve all categories in the datastore
      Returns:
      a list of all the Category instances in the datastore
    • readAllCategories

      @Nonnull List<Category> readAllCategories(@Nonnull int limit, @Nonnull int offset)
      Retrieve a subset of all categories
      Parameters:
      limit - the maximum number of results, defaults to 20
      offset - the starting point in the record set, defaults to 0
      Returns:
    • readTotalCategoryCount

      Long readTotalCategoryCount()
    • readAllProducts

      @Nonnull List<Product> readAllProducts()
      Retrieve all products in the datastore
      Returns:
      a list of all Category instances in the datastore, regardless of their category association
    • readAllProducts

      @Nonnull List<Product> readAllProducts(@Nonnull int limit, @Nonnull int offset)
    • readAllSubCategories

      @Nonnull List<Category> readAllSubCategories(@Nonnull Category category)
      Retrieve a list of all child categories of the passed in Category instance
      Parameters:
      category - the parent category
      Returns:
      a list of all child categories
    • readAllSubCategories

      @Nonnull List<Category> readAllSubCategories(@Nonnull Long id)
      Retrieve a list of all child categories of the passed in Category instance
      Parameters:
      id - the parent category ID
      Returns:
      a list of all child categories
    • readAllSubCategories

      @Nonnull List<Category> readAllSubCategories(@Nonnull Category category, @Nonnull int limit, @Nonnull int offset)
      Retrieve a list of all child categories of the passed in Category instance
      Parameters:
      category - the parent category
      limit - the maximum number of results to return
      offset - the starting point in the record set
      Returns:
      a list of all child categories
    • delete

      void delete(@Nonnull Category category)
      Removed the passed in Category instance from the datastore
      Parameters:
      category - the Category instance to remove
    • create

      @Nonnull Category create()
      Create a new Category instance. The system will use the configuration in /BroadleafCommerce/core/BroadleafCommerceFramework/src/main/resources/bl-framework-applicationContext-entity.xml to determine which polymorphic version of Category to instantiate. To make Broadleaf instantiate your extension of Category by default, include an entity configuration bean in your application context xml similar to:

       
           <bean id="blEntityConfiguration" class="org.broadleafcommerce.common.persistence.EntityConfiguration">
                <property name="entityContexts">
                    <list>
                        <value>classpath:myCompany-applicationContext-entity.xml</value>
                    </list>
                </property>
            </bean>
       
       

      Declare the same key for your desired entity in your entity xml that is used in the Broadleaf entity xml, but change the value to the fully qualified classname of your entity extension.
      Returns:
      a Category instance based on the Broadleaf entity configuration.
    • readActiveSubCategoriesByCategory

      @Nonnull List<Category> readActiveSubCategoriesByCategory(Category category)
      Retrieve a list of all active child categories of the passed in Category instance. This method bases its search on a current time value. To make the retrieval of values more efficient, the current time is cached for a configurable amount of time. See getCurrentDateResolution()
      Parameters:
      category - the parent category
      Returns:
      a list of all active child categories
    • readActiveSubCategoriesByCategory

      @Nonnull List<Category> readActiveSubCategoriesByCategory(@Nonnull Category category, @Nonnull int limit, @Nonnull int offset)
      Retrieve a list of all active child categories of the passed in Category instance. This method bases its search on a current time value. To make the retrieval of values more efficient, the current time is cached for a configurable amount of time. See getCurrentDateResolution()
      Parameters:
      category - the parent category
      limit - the maximum number of results to return
      offset - the starting point in the record set
      Returns:
      a list of all active child categories
    • findCategoryByURI

      Category findCategoryByURI(String uri)
    • getCurrentDateResolution

      Long getCurrentDateResolution()
      Returns the number of milliseconds that the current date/time will be cached for queries before refreshing. This aids in query caching, otherwise every query that utilized current date would be different and caching would be ineffective.
      Returns:
      the milliseconds to cache the current date/time
    • setCurrentDateResolution

      void setCurrentDateResolution(Long currentDateResolution)
      Sets the number of milliseconds that the current date/time will be cached for queries before refreshing. This aids in query caching, otherwise every query that utilized current date would be different and caching would be ineffective.
      Parameters:
      currentDateResolution - the milliseconds to cache the current date/time
    • readCountAllActiveProductsByCategory

      Long readCountAllActiveProductsByCategory(Category category)
    • findXrefByCategoryWithDefaultReference

      List<CategoryProductXref> findXrefByCategoryWithDefaultReference(Long categoryId)
      returns a list of CategoryProductXref where provided category is default reference(xref.defaultReference=true)
      Parameters:
      categoryId - long, id of the category
      Returns:
      returns a list of CategoryProductXref where provided category is default reference(xref.defaultReference=true)