Get a SQL "IN" clause for the number of items.

@param placeholderCount a count of "?" placeholders
@return a parenthetical String with {@code item.length} placeholders, eg. " (?,?,?,?) ".
@throws IllegalArgumentException if placeholderCount is negative
340618
public static String getInClausePlaceholdersForCount(final int placeholderCount)
   {
      // we cant overload method name because the only item for getInClausePlaceholders can be Integer which leads to ambiguity
      if (placeholderCount < 0)
      {
         throw new IllegalArgumentException("Placeholder count must be greater than or equal to zero");
      }
      if (placeholderCount == 0)
      {
         return " ('s0me n0n-ex1st4nt v4luu') ";
      }
      // items.length of "?" + items.length-1 of "," + 2 spaces + 2 brackets
      final StringBuilder sb = new StringBuilder(3 + placeholderCount * 2);
      sb.append(" (?");
      for (int i = 1; i < placeholderCount; i++)
      {
         sb.append(",?");
      }
      return sb.append(") ").toString();
   }
561550
public static String toCountSql(String sql) {
		sql = sql.replaceAll("select .*? from", "select count(*) from");
		sql = sql.replaceAll("SELECT .*? FROM", "SELECT count(*) FROM");
		sql = sql.replaceAll(" LIMIT.*", "");
		sql = sql.replaceAll(" limit.*", "");
		return sql;
	}
125191
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return commerceRegionPersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
258985
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return cpAttachmentFileEntryPersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
362154
private SqlNode getNthExpr(SqlNode query, int ordinal, int sourceCount) {
		if (query instanceof SqlInsert) {
			SqlInsert insert = (SqlInsert) query;
			if (insert.getTargetColumnList() != null) {
				return insert.getTargetColumnList().get(ordinal);
			} else {
				return getNthExpr(
					insert.getSource(),
					ordinal,
					sourceCount);
			}
		} else if (query instanceof SqlUpdate) {
			SqlUpdate update = (SqlUpdate) query;
			if (update.getTargetColumnList() != null) {
				return update.getTargetColumnList().get(ordinal);
			} else if (update.getSourceExpressionList() != null) {
				return update.getSourceExpressionList().get(ordinal);
			} else {
				return getNthExpr(
					update.getSourceSelect(),
					ordinal,
					sourceCount);
			}
		} else if (query instanceof SqlSelect) {
			SqlSelect select = (SqlSelect) query;
			if (select.getSelectList().size() == sourceCount) {
				return select.getSelectList().get(ordinal);
			} else {
				return query; // give up
			}
		} else {
			return query; // give up
		}
	}
630498
public static String createResultCountQuery(String query) {
        String resultCountQueryString = null;

        int select = query.toLowerCase().indexOf("select");
        int from = query.toLowerCase().indexOf("from");
        if (select == -1 || from == -1) {
            return null;
        }

        resultCountQueryString = "select count(" + query.substring(select + 6, from).trim() + ") " + query.substring(from);

        // remove order by
        // TODO: remove more parts
        if (resultCountQueryString.toLowerCase().contains("order by")) {
            resultCountQueryString = resultCountQueryString.substring(0, resultCountQueryString.toLowerCase().indexOf("order by"));
        }

        log.debug("Created query for counting results '{}'", resultCountQueryString);
        return resultCountQueryString;
    }
482837
private static <E> void validateCounter(Counter<E> counts) {
    for (Map.Entry<E, Double> entry : counts.entrySet()) {
      E item = entry.getKey();
      Double dblCount = entry.getValue();
      if (dblCount == null) {
        throw new IllegalArgumentException("ERROR: null count for item " + item + "!");
      }
      if (dblCount < 0) {
        throw new IllegalArgumentException("ERROR: negative count " + dblCount + " for item " + item + "!");
      }
    }
  }
1374943
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return cpDefinitionInventoryPersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
239106
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return commercePriceListPersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
348556
@Override
  public long executeCount(CommandContext commandContext) {
    checkQueryOk();
    DbReadOnlyIdentityServiceProvider identityProvider = getIdentityProvider(commandContext);
    return identityProvider.findTenantCountByQueryCriteria(this);
  }
1179895
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return cpRuleUserSegmentRelPersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
1164136
protected String getCountQuery() {
    
    if(dbConf.getInputCountQuery() != null) {
      return dbConf.getInputCountQuery();
    }
    
    StringBuilder query = new StringBuilder();
    query.append("SELECT COUNT(*) FROM " + tableName);

    if (conditions != null && conditions.length() > 0)
      query.append(" WHERE " + conditions);
    return query.toString();
  }
900945
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return cpOptionValuePersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
486686
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return cpRulePersistence.countWithDynamicQuery(dynamicQuery, projection);
	}
1165118
private void putPlaceholdersIntoMap(
      MsgNode originalMsg,
      Iterable<? extends SoyMsgPart> parts,
      Map<String, Function<Expression, Statement>> placeholderNameToPutStatement) {
    for (SoyMsgPart child : parts) {
      if (child instanceof SoyMsgRawTextPart || child instanceof SoyMsgPluralRemainderPart) {
        // raw text doesn't have placeholders and remainders use the same placeholder as plural they
        // are a member of.
        continue;
      }
      if (child instanceof SoyMsgPluralPart) {
        putPluralPartIntoMap(originalMsg, placeholderNameToPutStatement, (SoyMsgPluralPart) child);
      } else if (child instanceof SoyMsgSelectPart) {
        putSelectPartIntoMap(originalMsg, placeholderNameToPutStatement, (SoyMsgSelectPart) child);
      } else if (child instanceof SoyMsgPlaceholderPart) {
        putPlaceholderIntoMap(
            originalMsg, placeholderNameToPutStatement, (SoyMsgPlaceholderPart) child);
      } else {
        throw new AssertionError("unexpected child: " + child);
      }
    }
  }
810492
@Override
	public long dynamicQueryCount(DynamicQuery dynamicQuery,
		Projection projection) {
		return commerceUserSegmentEntryPersistence.countWithDynamicQuery(dynamicQuery,
			projection);
	}
866553
public int queryObjJoinCountByCondition(String sql){
		/*		JdbcTemplate jdbcTemplate = (JdbcTemplate) MicroDbHolder
		.getDbSource(dbName);*/
		JdbcTemplate jdbcTemplate = getMicroJdbcTemplate();
		logger.debug(sql);
		Integer total=jdbcTemplate.queryForObject(sql,Integer.class);
		return total;
	}