本文整理汇总了Java中org.springframework.jdbc.core.namedparam.NamedParameterUtils.buildSqlParameterList方法的典型用法代码示例。如果您正苦于以下问题:Java NamedParameterUtils.buildSqlParameterList方法的具体用法?Java NamedParameterUtils.buildSqlParameterList怎么用?Java NamedParameterUtils.buildSqlParameterList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.core.namedparam.NamedParameterUtils
的用法示例。
在下文中一共展示了NamedParameterUtils.buildSqlParameterList方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: openCursor
import org.springframework.jdbc.core.namedparam.NamedParameterUtils; //导入方法依赖的package包/类
@Override
protected void openCursor(Connection con) {
//MyParsedSqlDel parsedSql = getParsedSql(sql);
//String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql.getDelegate(), paramSource);
//String theSql = sqlToUse;
try {
// if (isUseSharedExtendedConnection()) {
// preparedStatement = con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
// ResultSet.HOLD_CURSORS_OVER_COMMIT);
// }
// else {
// preparedStatement = con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
// }
// applyStatementSettings(preparedStatement);
// if (this.preparedStatementSetter != null) {
//
//
// preparedStatementSetter.setValues(preparedStatement);
//
//
//
//
//
// }
// this.rs = preparedStatement.executeQuery();
ParsedSql parsedSql1 = this.getParsedSql(sql).getDelegate();
String sqlToUse1 = NamedParameterUtils.substituteNamedParameters(parsedSql1, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql1, paramSource, null);
List<SqlParameter> declaredParameters = NamedParameterUtils.buildSqlParameterList(parsedSql1, paramSource);
PreparedStatementCreatorFactory pscf = new PreparedStatementCreatorFactory(sqlToUse1, declaredParameters);
pscf.setResultSetType( ResultSet.TYPE_FORWARD_ONLY );
pscf.setUpdatableResults(false);
PreparedStatementCreator preparedStatementCreator = pscf.newPreparedStatementCreator(params);
//con.prepareStatement(theSql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
preparedStatement = preparedStatementCreator.createPreparedStatement(con);
this.rs = preparedStatement.executeQuery();
handleWarnings(preparedStatement);
}
catch (SQLException se) {
close();
throw getExceptionTranslator().translate("Executing query", getSql(), se);
}
}