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
(); 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 Summary
Constructors Constructor Description FlexibleSearchQuery(java.lang.String query)
FlexibleSearchQuery constructor.FlexibleSearchQuery(java.lang.StringBuilder sb)
FlexibleSearchQuery constructor.FlexibleSearchQuery(java.lang.String query, java.util.Map queryParams)
FlexibleSearchQuery constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addHints(Hint... hints)
Adds hints to Flexible Search query.void
addHints(java.util.List<? extends Hint> hints)
Adds hints to Flexible Search query.void
addQueryParameter(java.lang.String key, java.lang.Object value)
Add a query parameter to the search.void
addQueryParameters(java.util.Map<java.lang.String,? extends java.lang.Object> params)
Add a additional parameter map (String->Object) to the search.boolean
equals(java.lang.Object obj)
java.util.List<Hint>
getHints()
java.lang.String
getQuery()
java.util.Map<java.lang.String,java.lang.Object>
getQueryParameters()
int
hashCode()
java.lang.String
toString()
-
Methods inherited from class de.hybris.platform.servicelayer.search.AbstractQuery
getCatalogVersions, getCount, getLanguage, getLocale, getResultClassList, getSessionSearchRestrictions, getStart, getUser, isDisableCaching, isDisableSearchRestrictions, isDisableSpecificDbLimitSupport, isFailOnUnknownFields, isNeedTotal, setCatalogVersions, setCatalogVersions, setCount, setDisableCaching, setDisableSearchRestrictions, setDisableSpecificDbLimitSupport, setFailOnUnknownFields, setLanguage, setLocale, setNeedTotal, setResultClassList, setSessionSearchRestrictions, setSessionSearchRestrictions, setStart, setUser
-
-
-
-
Constructor Detail
-
FlexibleSearchQuery
public FlexibleSearchQuery(java.lang.String query)
FlexibleSearchQuery constructor. The query is mandatory and contains the flexible search string. Search parameters can be set withaddQueryParameter(String, Object)
/addQueryParameters(Map)
or instead use the constructorFlexibleSearchQuery(String, Map)
.- Parameters:
query
- the flexible search query
-
FlexibleSearchQuery
public FlexibleSearchQuery(java.lang.StringBuilder sb)
FlexibleSearchQuery constructor. The query is mandatory and contains the flexible search string builder. Search parameters can be set withaddQueryParameter(String, Object)
/addQueryParameters(Map)
or instead use the constructorFlexibleSearchQuery(String, Map)
.- Parameters:
sb
- the StringBuilder object containing flexible search query
-
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 queryqueryParams
- a Mapwith 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.
emptyCollection
value is not legal parameters.- Parameters:
key
- the key of the parametervalue
- 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 inparams
map is not legal.
emptyCollection
value inparams
map is not legal.- Parameters:
params
- the map
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.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 classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-