Class SkuDaoImpl

java.lang.Object
org.broadleafcommerce.core.catalog.dao.SkuDaoImpl
All Implemented Interfaces:
SkuDao

@Repository("blSkuDao") public class SkuDaoImpl extends Object implements SkuDao
Author:
Jeff Fischer
  • Field Details

    • em

      protected jakarta.persistence.EntityManager em
    • entityConfiguration

      protected EntityConfiguration entityConfiguration
    • sandBoxHelper

      protected SandBoxHelper sandBoxHelper
    • extensionManager

      protected SkuDaoExtensionManager extensionManager
    • currentDateResolution

      @Value("${query.dateResolution.sku:10000}") protected Long currentDateResolution
    • cachedDate

      protected Date cachedDate
  • Constructor Details

    • SkuDaoImpl

      public SkuDaoImpl()
  • Method Details

    • save

      public Sku save(Sku sku)
      Description copied from interface: SkuDao
      Persist a Sku instance to the datastore
      Specified by:
      save in interface SkuDao
      Parameters:
      sku - the sku to persist
      Returns:
      the saved state of the passed in sku
    • saveSkuFee

      public SkuFee saveSkuFee(SkuFee fee)
      Specified by:
      saveSkuFee in interface SkuDao
    • readSkuById

      public Sku readSkuById(Long skuId)
      Description copied from interface: SkuDao
      Retrieve a Sku instance by its primary key
      Specified by:
      readSkuById in interface SkuDao
      Parameters:
      skuId - the primary key of the sku
      Returns:
      the sku at the primary key
    • readSkuByExternalId

      public Sku readSkuByExternalId(String externalId)
      Description copied from interface: SkuDao
      Retrieve a Sku instance by its external id
      Specified by:
      readSkuByExternalId in interface SkuDao
      Parameters:
      externalId - the external id of the sku
      Returns:
      the sku with this external id
    • readSkuByUpc

      public Sku readSkuByUpc(String upc)
      Description copied from interface: SkuDao
      Queries for a Sku instance by its Universal Product Code (UPC).
      Specified by:
      readSkuByUpc in interface SkuDao
      Returns:
    • readFirstSku

      public Sku readFirstSku()
      Description copied from interface: SkuDao
      Retrieve the Sku instance whose primary key is the smallest of all skus in the datastore
      Specified by:
      readFirstSku in interface SkuDao
      Returns:
      the sku with the smallest primary key
    • readAllSkus

      public List<Sku> readAllSkus()
      Description copied from interface: SkuDao
      Retrieve all Sku instances from the datastore
      Specified by:
      readAllSkus in interface SkuDao
      Returns:
      the list of all skus
    • readAllSkus

      public List<Sku> readAllSkus(int offset, int limit)
      Description copied from interface: SkuDao
      Retrieve all Sku instances from the datastore
      Specified by:
      readAllSkus in interface SkuDao
      Parameters:
      offset - the starting offset of the query
      limit - the maximum number of Skus to gather
      Returns:
      the list of all skus in the given range
    • readSkusByIds

      public List<Sku> readSkusByIds(List<Long> skuIds)
      Description copied from interface: SkuDao
      Find all the Sku instances whose primary key matches one of the values from the passed in list
      Specified by:
      readSkusByIds in interface SkuDao
      Parameters:
      skuIds - the list of primary key values
      Returns:
      the list of skus that match the list of primary key values
    • delete

      public void delete(Sku sku)
      Description copied from interface: SkuDao
      Remove the Sku instance from the datastore
      Specified by:
      delete in interface SkuDao
      Parameters:
      sku - the sku to remove
    • create

      public Sku create()
      Description copied from interface: SkuDao
      Create a new Sku 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 Sku to instantiate. To make Broadleaf instantiate your extension of Sku 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.
      Specified by:
      create in interface SkuDao
      Returns:
      a Sku instance based on the Broadleaf entity configuration.
    • readCountAllActiveSkus

      public Long readCountAllActiveSkus()
      Description copied from interface: SkuDao
      Returns the number of Skus that are currently active.
      Specified by:
      readCountAllActiveSkus in interface SkuDao
      Returns:
      the number of currently active Skus
    • readCountAllActiveSkusInternal

      protected Long readCountAllActiveSkusInternal(Date currentDate)
    • readAllActiveSkus

      public List<Sku> readAllActiveSkus(int page, int pageSize)
      Description copied from interface: SkuDao
      Reads all Skus from the database that are currently active. This method utilizes database paging.

      It will fetch results in pages. For example, if page = 3 and pageSize = 25, this method would return rows 75-99 from the database.

      Specified by:
      readAllActiveSkus in interface SkuDao
      Parameters:
      page - - the number of the page to get (0 indexed)
      pageSize - - the number of results per page
      Returns:
      a list of active Skus for the given page
    • readAllActiveSkus

      public List<Sku> readAllActiveSkus(Integer pageSize, Long lastId)
      Description copied from interface: SkuDao
      Reads all skus from the database that are currently active. This method utilizes efficient paging to retrieve a subset of records. This approach does not use an offset technique (like SkuDao.readAllActiveSkus(int, int), but rather limits the retrieved records to those greater than the given id and returns a max results of pageSize. This is more efficient that using an offset, since the database will not have to retrieve all the records from the beginning of the table and trim the offset.
      Specified by:
      readAllActiveSkus in interface SkuDao
      Parameters:
      pageSize - the number of results per page
      lastId - the last id from the previous page - can be null if this is the first page request
      Returns:
      a list of active skus for the given page
    • getCurrentDateResolution

      public Long getCurrentDateResolution()
      Description copied from interface: SkuDao
      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.
      Specified by:
      getCurrentDateResolution in interface SkuDao
      Returns:
      the milliseconds to cache the current date/time
    • setCurrentDateResolution

      public void setCurrentDateResolution(Long currentDateResolution)
      Description copied from interface: SkuDao
      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.
      Specified by:
      setCurrentDateResolution in interface SkuDao
      Parameters:
      currentDateResolution - the milliseconds to cache the current date/time
    • findSkuByURI

      public List<Sku> findSkuByURI(String uri)
      Description copied from interface: SkuDao
      Look up a sku that matches the given URI
      Specified by:
      findSkuByURI in interface SkuDao
      Parameters:
      uri - - the relative URL to look up the sku by
      Returns:
      List of skus that match the passed in URI.
    • readAllActiveSkusInternal

      protected List<Sku> readAllActiveSkusInternal(int page, int pageSize, Date currentDate)
    • readAllActiveSkusInternal

      protected List<Sku> readAllActiveSkusInternal(Integer pageSize, Date currentDate, Long lastId)
    • getCriteriaForActiveSkus

      protected jakarta.persistence.criteria.CriteriaQuery<Sku> getCriteriaForActiveSkus(Date currentDate)
    • getCriteriaForActiveSkus

      protected jakarta.persistence.criteria.CriteriaQuery<Sku> getCriteriaForActiveSkus(Date currentDate, Long lastId)