本文整理汇总了Java中org.springframework.jdbc.core.namedparam.NamedParameterUtils.parseSqlStatement方法的典型用法代码示例。如果您正苦于以下问题:Java NamedParameterUtils.parseSqlStatement方法的具体用法?Java NamedParameterUtils.parseSqlStatement怎么用?Java NamedParameterUtils.parseSqlStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.core.namedparam.NamedParameterUtils
的用法示例。
在下文中一共展示了NamedParameterUtils.parseSqlStatement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processMethodParameters
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
private void processMethodParameters(List<ParameterProperties> parameterProperties) {
ParsedSql parsedSQL = NamedParameterUtils.parseSqlStatement(query);
try {
parametersNames = (List<String>) getParametersMethod.invoke(parsedSQL);
for (int i = 0; i < parametersNames.size(); i++) {
ParameterProperties properties = parameterProperties.get(i);
QueryParameterProcessor processor = QueryParameterProcessorFactory
.getQueryParameterProcessor(properties);
parameterMethodsList.add(processor);
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
示例2: updateNamed
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
public <T> int updateNamed(String namedSql, T bean) {
String sql = NamedParameterUtils.parseSqlStatementIntoString(namedSql);
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(namedSql);
BeanPropertySqlParameterSource source = new BeanPropertySqlParameterSource(bean);
List<SqlParameter> params = NamedParameterUtils.buildSqlParameterList(parsedSql, source);
Object[] args = NamedParameterUtils.buildValueArray(parsedSql, source, params);
return jdbcTemplate.update(sql, args);
}
示例3: getParsedSql
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
/**
* Obtain a parsed representation of this operation's SQL statement.
* <p>Typically used for named parameter parsing.
*/
protected ParsedSql getParsedSql() {
synchronized (this.parsedSqlMonitor) {
if (this.cachedSql == null) {
this.cachedSql = NamedParameterUtils.parseSqlStatement(getSql());
}
return this.cachedSql;
}
}
示例4: getPreparedStatementCreator
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
protected PreparedStatementCreator getPreparedStatementCreator(String sql, SqlParameterSource paramSource) {
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, paramSource);
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
return pscf.newPreparedStatementCreator(params);
}
示例5: getPreparedStatementCreator
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
protected PreparedStatementCreator getPreparedStatementCreator(String sql, Map<String,Object> paramMap) {
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, null);
List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, paramSource);
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
pscf.setReturnGeneratedKeys(true);
return pscf.newPreparedStatementCreator(params);
}
示例6: processStreamList
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
protected void processStreamList(Exchange exchange, String sql, SqlParameterSource param) throws Exception {
// spring JDBC to parse the SQL and build the prepared statement creator
// this is what NamedJdbcTemplate does internally
ParsedSql parsedSql = NamedParameterUtils.parseSqlStatement(sql);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, param);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, param, null);
List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql, param);
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse, declaredParameters);
PreparedStatementCreator statementCreator = pscf.newPreparedStatementCreator(params);
processStreamList(exchange, statementCreator, sqlToUse);
}
示例7: getParsedSql
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
/**
* Obtain a parsed representation of the given SQL statement.
* <p>The default implementation uses an LRU cache with an upper limit
* of 256 entries.
* @param sql the original SQL
* @return a representation of the parsed SQL statement
*/
protected ExposedParsedSql getParsedSql(String sql) {
if (getCacheLimit() <= 0) {
return new ExposedParsedSql( NamedParameterUtils.parseSqlStatement(sql) );
}
synchronized (this.parsedSqlCache) {
ExposedParsedSql parsedSql = this.parsedSqlCache.get(sql);
if (parsedSql == null) {
parsedSql = new ExposedParsedSql( NamedParameterUtils.parseSqlStatement(sql) );
this.parsedSqlCache.put(sql, parsedSql);
}
return parsedSql;
}
}