Class FlexibleSearchUtils

java.lang.Object
de.hybris.platform.util.FlexibleSearchUtils

public class FlexibleSearchUtils extends Object
  • Constructor Details

    • FlexibleSearchUtils

      public FlexibleSearchUtils()
  • Method Details

    • buildOracleCompatibleCollectionStatement

      public static String buildOracleCompatibleCollectionStatement(String expression, String parameter, String expressionOperator, Collection originalParameters, Map<String,Object> paramsMap)
      Builds oracle-proof collection conditions which respect the 1000 element limit for expressions in oracle.

      Example: Consider a condition

       {pk} IN ( ?coll )
       

      : This works fine on oracle provided that not more than 1000 elements are inside the collection. Otherwise you'll get the well known ORA-01795 error.

      Using this method would work like this:

              Collection params = ...
              Map<String,Object> queryParams = new HashMap();
              String query = "SELECT {PK} FROM {FOO} WHERE ";
              query += FlexibleSearchUtils.buildOracleCompatibleCollectionStatement( "{code} IN (?coll)","coll", "OR", params, queryParams );
       

      Finally you'd end up with conditions like this:

       ( {code} IN (?coll0) ) OR ( {code} IN (?coll1) OR ... )
       

      which is accepted by oracle.

      Another example with different connection operator

              Collection params = ...
              Map<String,Object> queryParams = new HashMap();
              String query = "SELECT {PK} FROM {FOO} WHERE ";
              query += FlexibleSearchUtils.buildOracleCompatibleCollectionStatement( "{code} NOT IN (?coll)","coll", "AND", params, queryParams );
       

      will end in

       ( {code} NOT IN (?coll0) ) AND ( {code} NOT IN (?coll1) OR ... )
       
      Parameters:
      expression - the condition containing the collection parameter
      parameter - the collection parameter alias (without '?')
      expressionOperator - the operator to be used in case the expression needs to be split up
      originalParameters - the original parameter value collection
      paramsMap - the FlexibleSearch parameter map to add the parameter value collection(s) to