Class DefaultPaginatedGenericDao<M extends ItemModel>

java.lang.Object
de.hybris.platform.servicelayer.search.paginated.dao.impl.DefaultPaginatedGenericDao<M>
All Implemented Interfaces:
PaginatedGenericDao<M>

public class DefaultPaginatedGenericDao<M extends ItemModel> extends Object implements PaginatedGenericDao<M>
Default implementation of PaginatedGenericDao
  • Constructor Details

    • DefaultPaginatedGenericDao

      public DefaultPaginatedGenericDao(String typeCode)
      Sets typeCode where this DefaultPaginatedGenericDao will search from. This constructor is an essential part of this Dao because it creates a query string based on the typeCode.
      Parameters:
      typeCode - the typeCode where this Dao will search from.
  • Method Details

    • find

      public SearchPageData<M> find(SearchPageData<M> searchPageData)
      Description copied from interface: PaginatedGenericDao
      Search for all instances of model given as a generic type using given sorts in SearchPageData to sort the results and return paginated results by specified pagination in SearchPageData.
      Specified by:
      find in interface PaginatedGenericDao<M extends ItemModel>
      Parameters:
      searchPageData - the searchPageData including sorts and pagination information to be applied in the results
      Returns:
      SearchPageData containing paginated and sorted search results
    • find

      public SearchPageData<M> find(Map<String,?> params, SearchPageData searchPageData)
      Description copied from interface: PaginatedGenericDao
      Search for all instances of model given as a generic type matching given FlexibleSearchQuery parameters.
      Specified by:
      find in interface PaginatedGenericDao<M extends ItemModel>
      Parameters:
      params - parameters to be added in search query's "WHERE" clause as Map with parameter name as a key and parameter value as a value.
      searchPageData - the searchPageData including sorts and pagination information to be applied in the results
      Returns:
      SearchPageData containing paginated and sorted search results
    • createFlexibleSearchQuery

      protected FlexibleSearchQuery createFlexibleSearchQuery(Map<String,?> params)
      Creates FlexibleSearchQuery for the typeCode and append "WHERE" clause with params, if given params is not empty.
      Parameters:
      params - the map containing FlexibleSearchQuery parameters
      Returns:
      FlexibleSearchQuery with query and queryParameters added if given params is not empty
    • createQueryString

      protected StringBuilder createQueryString()
      Creates a search query for the typeCode which is set from constructor
      Returns:
      StringBuilder with basic search query for the typeCode
    • appendWhereClausesToBuilder

      protected void appendWhereClausesToBuilder(StringBuilder builder, Map<String,?> params)
      Appends "WHERE" clause to the given builder with given params if it is not empty, otherwise do nothing
      Parameters:
      builder - the query builder containing "SELECT ... FROM ..." portion of query
      params - the map containing FlexibleSearchQuery parameters
    • getSortCodeToQueryAlias

      protected Map<String,String> getSortCodeToQueryAlias(SearchPageData searchPageData)
      Creates a map between sortCode to query alias which is required from PaginatedFlexibleSearchService to append "ORDER BY" clause. Because DefaultPaginatedGenericDao implementation will query from a single typeCode, all the sortCode will be mapped to the predefined QUERY_ALIAS

      While creating sortCodeToQueryAlias map, it uses lower case of sortData's code to meet the expectation of SortDataParsingStrategy

      Parameters:
      searchPageData - the searchPageData containing requested pagination and sorting information
      Returns:
      Map<String,String> containing sortCodeToQueryAlias
      See Also:
    • getPaginatedFlexibleSearchService

      protected PaginatedFlexibleSearchService getPaginatedFlexibleSearchService()
    • setPaginatedFlexibleSearchService

      public void setPaginatedFlexibleSearchService(PaginatedFlexibleSearchService paginatedFlexibleSearchService)