public Query getMiniSelectQuery(Collection<String> columns, Collection<Match> matches) {
        int matchSize = matches == null ? 0 : matches.size();

        int maxSqlLength = matches == null ? 50 : (matchSize + 3) * 10;
        StringBuilder sb = new StringBuilder(maxSqlLength);

        // SQL语句和参数列表的构造
        sb.append("select ");
        if (columns == null || columns.size() == 0) {
            sb.append("*,");
        } else {
            for (String column : columns) {
                sb.append(column).append(',');
            }
        }
        sb.deleteCharAt(sb.length() - 1);
        sb.append(" from ").append(dao.getTableName());

        if (matchSize == 0) {
            return new Query(sb.toString(), new ArrayList<Object>(0));
        }

        // 如果有条件
        List<Object> params = new ArrayList<Object>(matchSize + 1);
        appendQuerytoSQL(matches, sb, params);
        return new Query(sb.toString(), params);
    }
public Query getMiniSelectQuery ( Collection < String > columns , Collection < Match > matches ) { int matchSize = matches == null ? 0 : matches . size ( ) ; int maxSqlLength = matches == null ? 50 : ( matchSize + 3 ) * 10 ; StringBuilder sb = new StringBuilder ( maxSqlLength ) ; sb . append ( "select " ) ; if ( columns == null || columns . size ( ) == 0 ) { sb . append ( "*," ) ; } else { for ( String column : columns ) { sb . append ( column ) . append ( ',' ) ; } } sb . deleteCharAt ( sb . length ( ) - 1 ) ; sb . append ( " from " ) . append ( dao . getTableName ( ) ) ; if ( matchSize == 0 ) { return new Query ( sb . toString ( ) , new ArrayList < Object > ( 0 ) ) ; } List < Object > params = new ArrayList < Object > ( matchSize + 1 ) ; appendQuerytoSQL ( matches , sb , params ) ; return new Query ( sb . toString ( ) , params ) ; }
構造一個查詢的SQL語句。當columns為null或size為0時，即為select * ...

@param columns
@param matches

@return 下午1:14:54