构件相等条件的where语句<br>
如果没有条件语句，泽返回空串，表示没有条件

@param entity 条件实体
@param paramValues 条件值得存放List
@return 带where关键字的SQL部分
160995
public static String buildEqualsWhere(Entity entity, List<Object> paramValues) {
		if (null == entity || entity.isEmpty()) {
			return StrUtil.EMPTY;
		}

		final StringBuilder sb = new StringBuilder(" WHERE ");
		boolean isNotFirst = false;
		for (Entry<String, Object> entry : entity.entrySet()) {
			if (isNotFirst) {
				sb.append(" and ");
			} else {
				isNotFirst = true;
			}
			sb.append("`").append(entry.getKey()).append("`").append(" = ?");
			paramValues.add(entry.getValue());
		}

		return sb.toString();
	}
246976
public static void applyFetchProperties(MultivaluedMap<String, String> queryParams, Query query) {
        List<String> selectables = queryParams.get(FIELDS_PARAM_NAME);
        if (selectables != null) {
            StringBuilder selectBuilder = new StringBuilder();

            OrmQueryDetail detail = ((SpiQuery) query).getDetail();

            OrmQueryProperties base = detail.getChunk(null, false);
            if (base != null && StringUtils.isNotBlank(base.getProperties())) {
                // 获取已经设置的select
                selectBuilder.append(base.getProperties());
            }
            for (String s : selectables) {
                if (StringUtils.isBlank(s)) {
                    continue;
                }
                if (!s.startsWith("(")) {
                    s = "(" + s;
                }
                if (!s.startsWith(")")) {
                    s += ")";
                }
                BeanPathProperties pathProperties = BeanPathProperties.parse(s);
                for (BeanPathProperties.Props props : pathProperties.getPathProps()) {
                    String path = props.getPath();
                    String propsStr = props.getPropertiesAsString();

                    if (StringUtils.isEmpty(path)) {
                        if (selectBuilder.length() > 0) {
                            selectBuilder.append(",");
                        }
                        if (propsStr.length() > 0)
                            selectBuilder.append(propsStr);
                    } else if (StringUtils.isNotBlank(path)) {
                        FetchConfig config = null;
                        // 获取已经存在的fetch
                        OrmQueryProperties fetch = detail.getChunk(path, false);
                        if (fetch != null && StringUtils.isNotBlank(fetch.getProperties())) {
                            // 增加客户端传入值
                            propsStr = fetch.getProperties() + "," + propsStr;
                            config = fetch.getFetchConfig();
                        }
                        query.fetch(path, propsStr, config);
                    }
                }
            }
            if (selectBuilder.length() > 0) {
                query.select(selectBuilder.toString());
            }
        }
    }
997281
@Override
    public List<JsonEntityBean> getEntityBeans(List<String> params) {
        // if no parameters have been supplied, just return an empty list
        if (params == null || params.isEmpty()) {
            return Collections.<JsonEntityBean>emptyList();
        }

        List<JsonEntityBean> beans = new ArrayList<JsonEntityBean>();
        for (String param : params) {
            String[] parts = param.split(":", 2);
            JsonEntityBean member = getEntity(parts[0], parts[1], false);
            beans.add(member);
        }
        return beans;
    }
274011
public String queryString(String sql, Object... params) throws SQLException {
		return query(sql, new StringHandler(), params);
	}
993427
@Override
  public String getSqlWithValues() {
    final StringBuilder sb = new StringBuilder();
    final String statementQuery = getStatementQuery();

    // iterate over the characters in the query replacing the parameter placeholders
    // with the actual values
    int currentParameter = 0;
    for( int pos = 0; pos < statementQuery.length(); pos ++) {
      char character = statementQuery.charAt(pos);
      if( statementQuery.charAt(pos) == '?' && currentParameter <= parameterValues.size()) {
        // replace with parameter value
        Value value = parameterValues.get(currentParameter);
        sb.append(value != null ? value.toString() : new Value().toString());
        currentParameter++;
      } else {
        sb.append(character);
      }
    }

    return sb.toString();
  }
13395
static Map<String, String> findQueryParams(String baseParam, Method method) {
        Map<String, String> hrefVars = new HashMap<>();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        for (int i = 0; i < parameterAnnotations.length; i++) {
            Annotation[] paramAnnotations = parameterAnnotations[i];
            for (Annotation paramAnnotation : paramAnnotations) {
                Class<?> parameterClass = method.getParameterTypes()[i];
                hrefVars.putAll(findQueryParamOnParameter(baseParam, parameterClass, paramAnnotation));
            }
        }
        return hrefVars;
    }
319460
public List<Map<String, Object>> queryListMap(String sql, Object[] params) {
        Connection conn = getConn();
        try {
            return conn.createQuery(sql)
                    .withParams(params)
                    .setAutoDeriveColumnNames(true)
                    .throwOnMappingFailure(false)
                    .executeAndFetchTable()
                    .asList();
        } finally {
            this.closeConn(conn);
            this.clean(null);
        }
    }
1094398
public String getQuery(boolean withParams) {
        if (withParams) {
            StringBuffer sql = new StringBuffer(query);
            for (Object param : params) {
                int index = sql.indexOf("?");

                // 日期
                StringBuffer str;
                if (param instanceof Time) {
                    str = new StringBuffer(new SimpleDateFormat("HH:mm:ss").format(param));
                } else if (param instanceof Date || param instanceof java.sql.Date) {
                    str = new StringBuffer(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(param));
                } else {
                    str = new StringBuffer(param.toString());
                }

                // 非数字
                if (!(param instanceof Number)) {
                    str.insert(0, "'");
                    str.append("'");
                }
                sql.replace(index, index + 1, str.toString());
            }
            return sql.toString();
        } else {
            return getQuery();
        }
    }
1181456
@Override
    public Query<S> withValues(Object... values) {
        if (values == null || values.length == 0) {
            return this;
        }
        throw error();
    }
1222145
public static Map<String, Object> getKeyPropertyValues(EntityType entityType, Object entity) {
        Map<String, Object> keyPropertyValues = new HashMap<>();
        for (PropertyRef propertyRef : entityType.getKey().getPropertyRefs()) {
            String propertyName = propertyRef.getPath();
            Object propertyValue = getPropertyValue(entityType.getStructuralProperty(propertyName), entity);
            keyPropertyValues.put(propertyName, propertyValue);
        }
        return keyPropertyValues;
    }
155951
public long countBySql(String fullSql, Object[] paramValues, Type[] paramTypes){
        Session session = this.getCurrentSession();
    	Query query = session.createSQLQuery(fullSql);
    	setupQuery(query, paramValues, paramTypes, null, null);
        return ((Number)query.uniqueResult()).longValue();
    }
637537
public Page<T> page(String sql, List<Object> paramValues, PageRow pageRow) {
        return this.page(sql, paramValues.toArray(), pageRow);
    }
1083685
@RequestMapping(value = "/filter", method = RequestMethod.GET)
    public ResponseEntity<List<E>> findBySimpleFilter(@RequestParam MultiValueMap<String, String> requestParams) {

        final List<E> resultList = this.service.findBySimpleFilter(requestParams);

        if (resultList != null && !resultList.isEmpty()) {
            LOG.trace("Found a total of " + resultList.size()
                + " entities of type "
                + resultList.get(0).getClass().getSimpleName());
        }

        return new ResponseEntity<List<E>>(resultList, HttpStatus.OK);
    }
927557
public final List<T> findSortedByQuery(String query, String sort, Object... params) {
        return this.findSortedByQuery(query, sort, (Integer) null, (Integer) null, params);
    }
940839
public TResult queryForValueFieldValues(Map<String, ColumnValue> fieldValues) {
		String where = buildValueWhere(fieldValues.entrySet());
		String[] whereArgs = buildValueWhereArgs(fieldValues.values());
		TResult result = userDb.query(getTableName(), table.getColumnNames(),
				where, whereArgs, null, null, null);
		prepareResult(result);
		return result;
	}
917491
public @NotNull QueryStringBuilder params(@NotNull Map<String, Object> values) {
    for (Map.Entry<String, Object> entry : values.entrySet()) {
      param(entry.getKey(), entry.getValue());
    }
    return this;
  }
545709
public static String whereAllIfColumns(Class<?> entityClass, boolean empty, boolean useVersion) {
        StringBuilder sql = new StringBuilder();
        boolean hasLogicDelete = false;

        sql.append("<where>");
        //获取全部列
        Set<EntityColumn> columnSet = EntityHelper.getColumns(entityClass);
        EntityColumn logicDeleteColumn = SqlHelper.getLogicDeleteColumn(entityClass);
        //当某个列有主键策略时，不需要考虑他的属性是否为空，因为如果为空，一定会根据主键策略给他生成一个值
        for (EntityColumn column : columnSet) {
            if (!useVersion || !column.getEntityField().isAnnotationPresent(Version.class)) {
                // 逻辑删除，后面拼接逻辑删除字段的未删除条件
                if (logicDeleteColumn != null && logicDeleteColumn == column) {
                    hasLogicDelete = true;
                    continue;
                }
                sql.append(getIfNotNull(column, " AND " + column.getColumnEqualsHolder(), empty));
            }
        }
        if (useVersion) {
            sql.append(whereVersion(entityClass));
        }
        if (hasLogicDelete) {
            sql.append(whereLogicDelete(entityClass, false));
        }

        sql.append("</where>");
        return sql.toString();
    }