Class FlexibleSearchQuery

java.lang.Object
de.hybris.platform.servicelayer.search.AbstractQuery
de.hybris.platform.servicelayer.search.FlexibleSearchQuery

public class FlexibleSearchQuery extends AbstractQuery

The FlexibleSearchQuery stores all needed informations (the query itself, parameters, ...) to execute a search in the FlexibleSearchService. This class provides possibility to write much more cleaner code than with manually handling query and parameters. ... final Map queryParams = new HashMap<String, Object>(); queryParams.put("value", Boolean.TRUE); final FlexibleSearchQuery fQuery = new FlexibleSearchQuery("SELECT {PK} FROM {Language AS l} WHERE {l.active} = ?value ORDER BY {PK}", queryParams); fQuery. ...

Please note that this class is not thread-safe and not intended to be living longer than one request.

  • Constructor Details

    • FlexibleSearchQuery

      public FlexibleSearchQuery(String query)
      FlexibleSearchQuery constructor. The query is mandatory and contains the flexible search string. Search parameters can be set with addQueryParameter(String, Object) / addQueryParameters(Map) or instead use the constructor FlexibleSearchQuery(String, Map).
      Parameters:
      query - the flexible search query
    • FlexibleSearchQuery

      public FlexibleSearchQuery(StringBuilder sb)
      FlexibleSearchQuery constructor. The query is mandatory and contains the flexible search string builder. Search parameters can be set with addQueryParameter(String, Object) / addQueryParameters(Map) or instead use the constructor FlexibleSearchQuery(String, Map).
      Parameters:
      sb - the StringBuilder object containing flexible search query
    • FlexibleSearchQuery

      public FlexibleSearchQuery(String query, Map queryParams)
      FlexibleSearchQuery constructor. This constructor is used when the flexible search string contains additional search parameter which are added by the queryParams parameter. The key of the map are referenced in the flexible search query by ?<key>
      Parameters:
      query - the flexible search query
      queryParams - a Map<String, Object> with the additional search parameters
  • Method Details

    • addHints

      public void addHints(Hint... hints)
      Adds hints to Flexible Search query.
      Parameters:
      hints -
    • addHints

      public void addHints(List<? extends Hint> hints)
      Adds hints to Flexible Search query.
      Parameters:
      hints -
    • getHints

      public List<Hint> getHints()
    • addQueryParameter

      public void addQueryParameter(String key, Object value)

      Add a query parameter to the search. The key is referenced in the query (see getQuery()) with ?<key>

      Note that:
      null value is not legal parameters.
      empty Collection value is not legal parameters.

      Parameters:
      key - the key of the parameter
      value - the value of the parameter
    • addQueryParameters

      public void addQueryParameters(Map<String,? extends Object> params)

      Add a additional parameter map (String->Object) to the search. Each key is referenced in the query (see getQuery()) with ?<key>

      Note that:
      null value in params map is not legal.
      empty Collection value in params map is not legal.

      Parameters:
      params - the map
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getQuery

      public String getQuery()
      Returns:
      the flexible search query. This is not the translated SQL query.
    • getQueryParameters

      public Map<String,Object> getQueryParameters()
      Returns:
      all parameters for the search
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object