Class 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(); 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 Detail

      • FlexibleSearchQuery

        public FlexibleSearchQuery​(java.lang.String query,
                                   java.util.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 with the additional search parameters
    • Method Detail

      • addHints

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

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

        public java.util.List<Hint> getHints()
      • addQueryParameter

        public void addQueryParameter​(java.lang.String key,
                                      java.lang.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​(java.util.Map<java.lang.String,​? extends java.lang.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​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getQuery

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

        public java.util.Map<java.lang.String,​java.lang.Object> getQueryParameters()
        Returns:
        all parameters for the search
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object