Пример #1
0
  /** Convert named parameters into an OrderedList. */
  private void buildBindWhereRawSql(boolean buildSql, boolean parseRaw, DeployParser parser) {
    if (buildSql || bindParams != null) {
      whereRawSql = buildWhereRawSql();
      boolean hasRaw = !"".equals(whereRawSql);
      if (hasRaw && parseRaw) {
        // parse with encrypted property awareness. This means that if we have
        // an encrypted property we will insert special named parameter place
        // holders for binding the encryption key values
        parser.setEncrypted(true);
        whereRawSql = parser.parse(whereRawSql);
        parser.setEncrypted(false);
      }

      if (bindParams != null) {
        if (hasRaw) {
          whereRawSql =
              BindParamsParser.parse(bindParams, whereRawSql, request.getBeanDescriptor());

        } else if (query.isRawSql() && !buildSql) {
          // RawSql query hit cached query plan. Need to convert
          // named parameters into positioned parameters so that
          // the named parameters are bound
          RawSql.Sql sql = query.getRawSql().getSql();
          String s = sql.isParsed() ? sql.getPreWhere() : sql.getUnparsedSql();
          if (bindParams.requiresNamedParamsPrepare()) {
            BindParamsParser.parse(bindParams, s);
          }
        }
      }
    }
  }
Пример #2
0
 private void buildBindHavingRawSql(
     boolean buildSql, boolean parseRaw, DeployParser deployParser) {
   if (buildSql || bindParams != null) {
     // having clause with named parameters...
     havingRawSql = query.getAdditionalHaving();
     if (parseRaw) {
       havingRawSql = deployParser.parse(havingRawSql);
     }
     if (havingRawSql != null && bindParams != null) {
       // convert and order named parameters if required
       havingNamedParams = BindParamsParser.parseNamedParams(bindParams, havingRawSql);
       havingRawSql = havingNamedParams.getPreparedSql();
     }
   }
 }