public static void processDynamicFilterParameters(
      final String sqlFragment, final ParameterContainer container, final HqlSqlWalker walker) {
    if (walker.getEnabledFilters().isEmpty()
        && (!hasDynamicFilterParam(sqlFragment))
        && (!(hasCollectionFilterParam(sqlFragment)))) {
      return;
    }

    Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
    String symbols =
        new StringBuffer()
            .append(ParserHelper.HQL_SEPARATORS)
            .append(dialect.openQuote())
            .append(dialect.closeQuote())
            .toString();
    StringTokenizer tokens = new StringTokenizer(sqlFragment, symbols, true);
    StringBuffer result = new StringBuffer();

    while (tokens.hasMoreTokens()) {
      final String token = tokens.nextToken();
      if (token.startsWith(ParserHelper.HQL_VARIABLE_PREFIX)) {
        final String filterParameterName = token.substring(1);
        final String[] parts = LoadQueryInfluencers.parseFilterParameterName(filterParameterName);
        final FilterImpl filter = (FilterImpl) walker.getEnabledFilters().get(parts[0]);
        final Object value = filter.getParameter(parts[1]);
        final Type type = filter.getFilterDefinition().getParameterType(parts[1]);
        final String typeBindFragment =
            StringHelper.join(
                ",",
                ArrayHelper.fillArray(
                    "?", type.getColumnSpan(walker.getSessionFactoryHelper().getFactory())));
        final String bindFragment =
            (value != null && Collection.class.isInstance(value))
                ? StringHelper.join(
                    ",", ArrayHelper.fillArray(typeBindFragment, ((Collection) value).size()))
                : typeBindFragment;
        result.append(bindFragment);
        container.addEmbeddedParameter(
            new DynamicFilterParameterSpecification(parts[0], parts[1], type));
      } else {
        result.append(token);
      }
    }

    container.setText(result.toString());
  }
  protected void initPropertyPaths(
      final String path,
      final Type type,
      String[] columns,
      final String[] formulaTemplates,
      final Mapping factory)
      throws MappingException {

    if (columns.length != type.getColumnSpan(factory)) {
      throw new MappingException("broken column mapping for: " + path + " of: " + getEntityName());
    }

    if (type.isAssociationType()) {
      AssociationType actype = (AssociationType) type;
      if (actype.useLHSPrimaryKey()) {
        columns = getIdentifierColumnNames();
      } else {
        String foreignKeyProperty = actype.getLHSPropertyName();
        if (foreignKeyProperty != null && !path.equals(foreignKeyProperty)) {
          // TODO: this requires that the collection is defined after the
          //      referenced property in the mapping file (ok?)
          columns = (String[]) columnsByPropertyPath.get(foreignKeyProperty);
          if (columns == null) return; // get em on the second pass!
        }
      }
    }

    if (path != null) addPropertyPath(path, type, columns, formulaTemplates);

    if (type.isComponentType()) {
      AbstractComponentType actype = (AbstractComponentType) type;
      initComponentPropertyPaths(path, actype, columns, formulaTemplates, factory);
      if (actype.isEmbedded()) {
        initComponentPropertyPaths(
            path == null ? null : StringHelper.qualifier(path),
            actype,
            columns,
            formulaTemplates,
            factory);
      }
    } else if (type.isEntityType()) {
      initIdentifierPropertyPaths(path, (EntityType) type, columns, factory);
    }
  }