Class IckleQueryOperators
java.lang.Object
org.keycloak.models.map.storage.hotRod.IckleQueryOperators
This class provides knowledge on how to build Ickle query where clauses for specified
ModelCriteriaBuilder.Operator
.
For example,
for operator ModelCriteriaBuilder.Operator.EQ
we concatenate left operand and right operand with equal sign:
fieldName = :parameterName
however, for operator ModelCriteriaBuilder.Operator.EXISTS
we add following:
fieldName IS NOT NULL AND fieldName IS NOT EMPTY"
.
For right side operands we use named parameters to avoid injection attacks. Mapping between named parameter and
corresponding value is then saved into Map<String, Object>
that is passed to each IckleQueryOperators.ExpressionCombinator
.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
combineExpressions
(ModelCriteriaBuilder.Operator op, String modelFieldName, Object[] values, Map<String, Object> parameters) Provides a string containing where clause for given operator, field name and valuesstatic String
findAvailableNamedParam
(Set<String> existingNames, String namePrefix) MapsnamePrefix
to next available parameter name.
-
Field Details
-
C
- See Also:
-
-
Constructor Details
-
IckleQueryOperators
public IckleQueryOperators()
-
-
Method Details
-
findAvailableNamedParam
MapsnamePrefix
to next available parameter name. For example, ifnamePrefix == "id"
andexistingNames
set already containsid0
andid1
it returnsid2
. Any character that is not an alphanumeric will be stripped, so that it works for prefixes like"attributes.name"
as well. This method is used for computing available names for name query parameters. Instead of creating generic named parameters that would be hard to debug and read by humans, it creates readable named parameters from the prefix.- Parameters:
existingNames
- set of parameter names that are already used in this Ickle querynamePrefix
- name of the parameter- Returns:
- next available parameter name
-
combineExpressions
public static String combineExpressions(ModelCriteriaBuilder.Operator op, String modelFieldName, Object[] values, Map<String, Object> parameters) Provides a string containing where clause for given operator, field name and values- Parameters:
op
- operatormodelFieldName
- field namevalues
- valuesparameters
- mapping between named parameters and their values- Returns:
- where clause
-