站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

NamedParameterUtils (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.jdbc.core.namedparam
Class NamedParameterUtils

java.lang.Object
  extended by org.springframework.jdbc.core.namedparam.NamedParameterUtils

public abstract class NamedParameterUtils
extends Object

Helper methods for named parameter parsing. Only intended for internal use within Spring's JDBC framework.

Since:
2.0
Author:
Thomas Risberg, Juergen Hoeller

Constructor Summary
NamedParameterUtils()
           
 
Method Summary
static Object[] buildValueArray(ParsedSql parsedSql, SqlParameterSource paramSource, List declaredParams)
          Convert a Map of named parameter values to a corresponding array.
static Object[] buildValueArray(String sql, Map paramMap)
          Convert a Map of named parameter values to a corresponding array.
static ParsedSql parseSqlStatement(String sql)
          Parse the SQL statement and locate any placeholders or named parameters.
static String parseSqlStatementIntoString(String sql)
          Parse the SQL statement and locate any placeholders or named parameters.
static String substituteNamedParameters(ParsedSql parsedSql, SqlParameterSource paramSource)
          Parse the SQL statement and locate any placeholders or named parameters.
static String substituteNamedParameters(String sql, SqlParameterSource paramSource)
          Parse the SQL statement and locate any placeholders or named parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedParameterUtils

public NamedParameterUtils()
Method Detail

parseSqlStatement

public static ParsedSql parseSqlStatement(String sql)
Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder.

Parameters:
sql - the SQL statement
Returns:
the parsed statement, represented as ParsedSql instance

substituteNamedParameters

public static String substituteNamedParameters(ParsedSql parsedSql,
                                               SqlParameterSource paramSource)
Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder and any select list is expanded to the required number of placeholders.

The parameter values passed in are used to determine the number of placeholder to be used for a select list. Select lists should be limited to 100 or fewer elements. A larger number of elements is not guaramteed to be supported by the database and is strictly vendor-dependent.

Parameters:
parsedSql - the parsed represenation of the SQL statement
paramSource - the source for named parameters
Returns:
the SQL statement with substituted parameters
See Also:
parseSqlStatement(java.lang.String)

buildValueArray

public static Object[] buildValueArray(ParsedSql parsedSql,
                                       SqlParameterSource paramSource,
                                       List declaredParams)
Convert a Map of named parameter values to a corresponding array.

Parameters:
parsedSql - the parsed SQL statement
paramSource - the source for named parameters
declaredParams - the List of declared SqlParameter objects (may be null). If specified, the parameter metadata will be built into the value array in the form of SqlParameterValue objects.
Returns:
the array of values

parseSqlStatementIntoString

public static String parseSqlStatementIntoString(String sql)
Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder.

This is a shortcut version of parseSqlStatement(String) in combination with substituteNamedParameters(ParsedSql, SqlParameterSource).

Parameters:
sql - the SQL statement
Returns:
the actual (parsed) SQL statement

substituteNamedParameters

public static String substituteNamedParameters(String sql,
                                               SqlParameterSource paramSource)
Parse the SQL statement and locate any placeholders or named parameters. Named parameters are substituted for a JDBC placeholder and any select list is expanded to the required number of placeholders.

This is a shortcut version of substituteNamedParameters(ParsedSql, SqlParameterSource).

Parameters:
sql - the SQL statement
paramSource - the source for named parameters
Returns:
the SQL statement with substituted parameters

buildValueArray

public static Object[] buildValueArray(String sql,
                                       Map paramMap)
Convert a Map of named parameter values to a corresponding array.

This is a shortcut version of buildValueArray(ParsedSql, SqlParameterSource, java.util.List).

Parameters:
sql - the SQL statement
paramMap - the Map of parameters
Returns:
the array of values

The Spring Framework

Copyright © 2002-2007 The Spring Framework.