Get the SQL SELECT string.
@param bUseCurrentValues If true, use the current field value, otherwise, use '?'.
@param vParamList The parameter list.
@return The SQL select string.
771628
public String getSQLQuery(boolean bUseCurrentValues, Vector<BaseField> vParamList)
    {
        String strRecordset = this.makeTableNames(false);
        String strFields = this.getSQLFields(DBConstants.SQL_SELECT_TYPE, bUseCurrentValues);
        boolean bIsQueryRecord = this.isQueryRecord();
        String strSortParams = this.addSortParams(bIsQueryRecord, true);

        this.handleInitialKey();        // Set up the smaller key
        String strStartRange = this.addSelectParams(">=", DBConstants.START_SELECT_KEY, true, bIsQueryRecord, bUseCurrentValues, vParamList, true, false);   // Add only if changed
        this.handleEndKey();            // Set up the larger key
        String strEndRange = this.addSelectParams("<=", DBConstants.END_SELECT_KEY, true, bIsQueryRecord, bUseCurrentValues, vParamList, true, false);   // Add only if changed
        String strWhere = DBConstants.BLANK;
        if (strStartRange.length() == 0)
            strWhere = strEndRange;
        else
        {
            if (strEndRange.length() == 0)
                strWhere = strStartRange;
            else
                strWhere = strStartRange + " AND " + strEndRange;
        }
        //      Next, get the recordset filter
            StringBuffer strbFilter = new StringBuffer();
            this.handleRemoteCriteria(strbFilter, bIsQueryRecord, vParamList);  // Add any selection criteria (from behaviors)
            if (strbFilter.length() > 0)
            {
                if (strWhere.length() == 0)
                    strWhere = strbFilter.toString();
                else
                    strWhere += " AND (" + strbFilter.toString() + ")";
            }

        if (strWhere.length() > 0)
            strWhere = " WHERE " + strWhere;
        strRecordset = "SELECT" + strFields + " FROM " + strRecordset + strWhere + strSortParams;
        return strRecordset;
    }
542740
@Override
	public Map<String, Object> getOutParams(final CallableStatement callableStatement) throws SQLException {
		Map<String, Object> out = new HashMap<>();
		Parameter[] bindParameters = getBindParameters();
		int parameterIndex = 1;
		for (Parameter parameter : bindParameters) {
			if (parameter instanceof OutParameter) {
				String key = parameter.getParameterName();
				out.put(key, getSqlFilterManager().doOutParameter(key, callableStatement.getObject(parameterIndex)));
			}
			parameterIndex++;
		}

		LOG.debug("Stored procedure out parameter[{}]", out);
		return out;
	}
302034
private Object getParameterValue(ControlBeanContext context, Method method, Object[] args) {
        Object value;
        try {
            value = context.getParameterValue(method, _nameQualifiers[0], args);
        } catch (IllegalArgumentException iae) {
            throw new ControlException("Invalid argument name in SQL statement: " + _nameQualifiers[0], iae);
        }

        for (int i = 1; i < _nameQualifiers.length; i++) {
            // handle maps, properties, and fields...
            value = extractValue(value, _nameQualifiers[i - 1], _nameQualifiers[i]);
        }
        return value;
    }
860776
public int append2SQLSelect(final SQLSelect _select,
                                final int _colIndex)
        throws EFapsException
    {
        final Type type;
        if (this.selectParts.size() > 0) {
            type = this.selectParts.get(this.selectParts.size() - 1).getType();
        } else {
            type = this.query.getMainType();
        }
        final int ret;
        if (this.valueSelect == null) {
            ret = this.fromSelect.getMainOneSelect().getValueSelect().append2SQLSelect(type, _select, this.tableIndex,
                                                                                       _colIndex);
        } else {
            ret = this.valueSelect.append2SQLSelect(type, _select, this.tableIndex, _colIndex);
        }

        return ret;
    }
1025694
private static String getStringValueFromRow(QuerySolution resultRow, String variableName) {
        // Check the input and exit immediately if null
        if (resultRow == null) {
            return null;
        }

        String result = null;

        Resource res = resultRow.getResource(variableName);
        if (res != null && res.isLiteral()) {
            result = res.asLiteral().getString();
        }

        return result;
    }
919288
public static String getOptionalStringParameter(Map<String, String> parameters,
                                                    String parameterName,
                                                    String defaultValue) {
        validateParameters(parameters);
        validateParameterName(parameterName);

        String value = parameters.get(parameterName);
        return value == null ? defaultValue : value;
    }
126084
public static String getPagingClause (String sql,Criteria crt) {
        if (null == sql ) return null;
        if (null == crt) return sql;

        if (crt.getLimit()>0) {
            String databaseType = JibuConfig.getProperty("databaseType");
            if("Derby".equals(databaseType)) {
                // 参考 ：http://db.apache.org/derby/docs/dev/ref/rrefsqljoffsetfetch.html
                return  sql  + " OFFSET "+crt.getStart()+" ROWS FETCH NEXT "+crt.getLimit()+" ROWS ONLY ";
            } else if("PostgreSQL".equals(databaseType) || "MySQL".equals(databaseType)) {
                return  sql  + " LIMIT "+crt.getLimit()+" OFFSET "+crt.getStart()+" ";
            } else if("Oracle".equals(databaseType)) {
                // http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:127412348064
                return (" SELECT * \n"+ 
                        " FROM ( SELECT a.*, rownum rnum \n"+
                        "        FROM ( "+ sql +" ) a \n"+
                        "        WHERE rownum < "+(crt.getStart()+crt.getLimit())+" ) \n"+
                        " WHERE rnum >= "+crt.getStart());
            }
        }
        return sql;
    }
838890
public static String sqlValueToString(ResultSet rs, int index, int sqlType) throws SQLException {
        Class<?> requiredType = sqlTypeToJavaTypeMap.get(sqlType);
        if (requiredType == null) {
            throw new IllegalArgumentException("unknow java.sql.Types - " + sqlType);
        }

        return getResultSetValue(rs, index, requiredType);
    }
1255888
public static List<Map<String, Object>> getListMap(String sql, Object... arg) {
        Connection connection = JDBCUtils.getConnection();
        PreparedStatement ps = null;
        ResultSet result = null;
        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
        try {
            ps = connection.prepareStatement(sql);
            for (int i = 0; i < arg.length; i++) {
                ps.setObject(i + 1, arg[i]);
            }

            result = ps.executeQuery();
            listMap = DBUtils.handleResultSetToMapList(result, listMap);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.release(result, ps, connection);
        }
        return listMap;
    }
536669
public List<Blog> selectPublicBlogs() throws SQLException {

      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      List<Blog> blogs = Lists.newArrayListWithExpectedSize(4);
      Timer.Context ctx = metrics.selectBlogsTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(selectPublicBlogsSQL);
         rs = stmt.executeQuery();
         while(rs.next()) {
            blogs.add(blogFromResultSet(rs));
         }
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt, rs);
      }

      return blogs;
   }
771142
public boolean doRemoteCriteria(StringBuffer strbFilter, boolean bIncludeFileName, Vector<BaseField> vParamList)
    {
        BaseField fldTarget = null;
        if (typeFieldName != null)
            fldTarget = this.getOwner().getField(typeFieldName);
        else
            fldTarget = this.getOwner().getField(m_iTypeField);
        String strToCompare = Integer.toString(m_iTargetValue);
        boolean bDontSkip = this.fieldCompare(fldTarget, strToCompare, DBConstants.EQUALS, strbFilter, bIncludeFileName, vParamList);
        if (strbFilter != null)
            bDontSkip = true; // Don't need to compare, if I'm creating a filter to pass to SQL 
        if (bDontSkip)
            return super.doRemoteCriteria(strbFilter, bIncludeFileName, vParamList);    // Dont skip this record
        else
            return false;   // Skip this one
    }
147526
public CharSequence getQueryColumns(String tabalis, SelectColumn selects) {
        if (selects == null) return tabalis == null ? "*" : (tabalis + ".*");
        StringBuilder sb = new StringBuilder();
        for (Attribute attr : this.attributes) {
            if (!selects.test(attr.field())) continue;
            if (sb.length() > 0) sb.append(',');
            sb.append(getSQLColumn(tabalis, attr.field()));
        }
        if (sb.length() == 0) sb.append('*');
        return sb;
    }
637537
public Page<T> page(String sql, List<Object> paramValues, PageRow pageRow) {
        return this.page(sql, paramValues.toArray(), pageRow);
    }
584145
public List<?> selectList(String statement, Object parameter){
    statement = dbSqlSessionFactory.mapStatement(statement);
    List<Object> resultList = sqlSession.selectList(statement, parameter);
    for (Object object : resultList) {
      fireEntityLoaded(object);
    }
    return resultList;
  }
933759
public List<Map<String, Object>> selectList(String sql) {
        String msId = msUtils.select(sql);
        return sqlSession.selectList(msId);
    }
1182563
public String getSQLDelete(boolean bUseCurrentValues)
    {
        String strRecordset = this.getBaseRecord().makeTableNames(false);

        KeyArea keyArea = this.getKeyArea(0); // Primary index
        boolean bIsQueryRecord = this.isQueryRecord();
        boolean bUseCurrentKeyValues = bUseCurrentValues ? true : keyArea.isNull(DBConstants.TEMP_KEY_AREA, false);
        String sFilter = "?";
        sFilter = keyArea.addSelectParams("=", DBConstants.TEMP_KEY_AREA, false, bIsQueryRecord, bUseCurrentKeyValues, null, true, false);    // Always add!?
        if (sFilter.length() > 0)
            sFilter = " WHERE " + sFilter;

        strRecordset = "DELETE FROM " + strRecordset + sFilter;

        return strRecordset;
    }
453077
public <T> List<T> selectList(String sql, Object value, Class<T> resultType) {
        String msId;
        Class<?> parameterType = value != null ? value.getClass() : null;
        if (resultType == null) {
            msId = msUtils.selectDynamic(sql, parameterType);
        } else {
            msId = msUtils.selectDynamic(sql, parameterType, resultType);
        }
        return sqlSession.selectList(msId, value);
    }